From: Igor Munkin <imun@tarantool.org>
To: HustonMmmavr <huston.mavr@gmail.com>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2] fio: fix race condition in mktree
Date: Mon, 13 Jan 2020 15:28:54 +0300 [thread overview]
Message-ID: <20200113122854.GH31304@tarantool.org> (raw)
In-Reply-To: <20200113121449.36540-1-huston.mavr@gmail.com>
Hello,
Thanks, LGTM.
Cced Sasha Tu. to proceed with the patch.
On 13.01.20, HustonMmmavr wrote:
> Despite the lack of documentation, fio.mktree() was designed to work
> similar to mkdir -p: it creates the directory along with it's parents
> and doesn't complain about existing ones.
>
> But this function was subject to a race if two different processes were
> trying to create the same directory at the same time. It was caused by
> the fact that directory existence check and its creation aren't atomic.
>
> This patch fixes the race by impoving error handling: it's not an error
> if directory exists, even if it was created by someone else and mktree
> failed.
>
> Related to https://github.com/tarantool/doc/issues/1063
Side note: you can mention the ticket from other repo queue the
following way:
| Relates to tarantool/doc#1063
> Closes #4660
> ---
> branch: https://github.com/tarantool/tarantool/tree/HustonMmmavr/gh-4660-fix-fio-mktree-race
>
> 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
>
--
Best regards,
IM
next prev parent reply other threads:[~2020-01-13 12:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-13 12:14 HustonMmmavr
2020-01-13 12:28 ` Igor Munkin [this message]
2020-01-13 15:44 ` Alexander Turenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200113122854.GH31304@tarantool.org \
--to=imun@tarantool.org \
--cc=huston.mavr@gmail.com \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v2] fio: fix race condition in mktree' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox