Hi Michael,

The patches are attached.  To make reviewing easier we spilt them into small
pieces:

- v1-0001-Fix-race-condition-in-pg_mkdir_p.patch: the fix to pg_mkdir_p()
  itself, basically we are following the `mkdir -p` logic;
- v1-0002-Test-concurrent-call-to-pg_mkdir_p.patch: the tests for
pg_mkdir_p(),
  we could see how it fails by reverting the first patch, and a reproducer
with
  initdb is also provided in the README; as we do not know how to create a
unit
  test in postgresql we have to employ a test module to do the job, not
sure if
  this is a proper solution;
- v1-0003-Fix-callers-of-pg_mkdir_p.patch &
  v1-0004-Fix-callers-of-MakePGDirectory.patch: fix callers of pg_mkdir_p()
and
  MakePGDirectory(), tests are not provided for these changes;

MakePGDirectory() is also called in TablespaceCreateDbspace(), EEXIST is
considered as non-error for parent directories, however as it considers
EEXIST
as a failure for the last level of the path so the logic is still correct,
we
do not add a final stat() check for it.

Best Regards
Ning


On Thu, Jul 18, 2019 at 4:57 PM Michael Paquier <mich...@paquier.xyz> wrote:

> On Thu, Jul 18, 2019 at 04:17:22PM +0800, Ning Yu wrote:
> > This is still wrong with current code logic, because when the statusdir
> is
> > a file the errno is also EEXIST, but it can pass the check here.  Even if
> > we fix pg_mkdir_p() by following the `mkdir -p` way the errno check here
> is
> > still wrong.
>
> Would you like to send a patch?
> --
> Michael
>

Attachment: v1-0003-Fix-callers-of-pg_mkdir_p.patch
Description: Binary data

Attachment: v1-0004-Fix-callers-of-MakePGDirectory.patch
Description: Binary data

Attachment: v1-0002-Test-concurrent-call-to-pg_mkdir_p.patch
Description: Binary data

Attachment: v1-0001-Fix-race-condition-in-pg_mkdir_p.patch
Description: Binary data

Reply via email to