* [Tarantool-patches] [PATCH] fio: fix race condition in mktree
@ 2019-12-17 15:52 HustonMmmavr
2020-01-10 11:33 ` Igor Munkin
0 siblings, 1 reply; 2+ messages in thread
From: HustonMmmavr @ 2019-12-17 15:52 UTC (permalink / raw)
To: tarantool-patches, imun
This patch fixes a bug that occours when two instances calls
fio.mktree for the same directory in parallel.
Closes #4660
---
branch: https://github.com/tarantool/tarantool/tree/HustonMmmavr/gh-4660-fix-fio-mktree-race
issue: https://github.com/tarantool/tarantool/issues/4660
src/lua/fio.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lua/fio.lua b/src/lua/fio.lua
index cb224f3d0..c9aeac951 100644
--- a/src/lua/fio.lua
+++ b/src/lua/fio.lua
@@ -364,7 +364,7 @@ fio.mktree = function(path, mode)
local stat = fio.stat(current_dir)
if stat == nil then
local st, err = fio.mkdir(current_dir, mode)
- if err ~= nil then
+ if err ~= nil and not fio.path.is_dir(current_dir) then
return false, string.format("Error creating directory %s: %s",
current_dir, tostring(err))
end
--
2.23.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Tarantool-patches] [PATCH] fio: fix race condition in mktree
2019-12-17 15:52 [Tarantool-patches] [PATCH] fio: fix race condition in mktree HustonMmmavr
@ 2020-01-10 11:33 ` Igor Munkin
0 siblings, 0 replies; 2+ messages in thread
From: Igor Munkin @ 2020-01-10 11:33 UTC (permalink / raw)
To: HustonMmmavr; +Cc: tarantool-patches
Hello,
Thanks for the patch. Here are some general comments for the patch:
* Why this patch is necessary? I see no words in documentation about the
concurrent path creation and corresponding errors. Therefore
considering our docs everything works as described. If you see this as
a gray zone, please file a ticket to tarantool/doc[1] repo for
adjusting the fio docs regarding the changes you provide.
* If you are affected with such behaviour please describe the problem
you faced with a bit more words in the commit message (since the word
"parallel" is ambigous for this case) and provide a test case
regarding your fix if possible.
There are also several comments below, please also consider them.
On 17.12.19, HustonMmmavr wrote:
> This patch fixes a bug that occours when two instances calls
Typo: s/occours/occurs/.
Typo: s/calls/call/.
> fio.mktree for the same directory in parallel.
>
> Closes #4660
> ---
> branch: https://github.com/tarantool/tarantool/tree/HustonMmmavr/gh-4660-fix-fio-mktree-race
> issue: https://github.com/tarantool/tarantool/issues/4660
>
> src/lua/fio.lua | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lua/fio.lua b/src/lua/fio.lua
> index cb224f3d0..c9aeac951 100644
> --- a/src/lua/fio.lua
> +++ b/src/lua/fio.lua
> @@ -364,7 +364,7 @@ fio.mktree = function(path, mode)
> local stat = fio.stat(current_dir)
> if stat == nil then
> local st, err = fio.mkdir(current_dir, mode)
> - if err ~= nil then
> + if err ~= nil and not fio.path.is_dir(current_dir) then
Side note: it's weird to check the second optional result value to
detect the failure instead of the first one. Feel free to ignore.
> return false, string.format("Error creating directory %s: %s",
> current_dir, tostring(err))
> end
> --
> 2.23.0
>
[1]: https://github.com/tarantool/doc
--
Best regards,
IM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-10 11:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17 15:52 [Tarantool-patches] [PATCH] fio: fix race condition in mktree HustonMmmavr
2020-01-10 11:33 ` Igor Munkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox