fix pg_mkdir_p to tolerate concurrent directory creation - Mailing list pgsql-hackers

From Andrew Dunstan
Subject fix pg_mkdir_p to tolerate concurrent directory creation
Date
Msg-id 3ca004de-e49b-4471-b8aa-fd656e70f68c@dunslane.net
Whole thread
Responses Re: fix pg_mkdir_p to tolerate concurrent directory creation
List pgsql-hackers
While working on the pytest stuff, I found this issue when making it 
work on Windows, but the issue can exist everywhere. pg_mkdir_p can fail 
if there is a concurrent directory creation. This patch makes it 
tolerant of concurrent directory creation. To make it more robust it 
stops using stat() on Windows and instead uses GetFileAttributes().

I think this makes the function actually meet the contract set out in 
the file's header comment:

  * pg_mkdir_p --- create a directory and, if necessary, parent directories
  *
  * This is equivalent to "mkdir -p" except we don't complain if the target
  * directory already exists.

Thanks to Bryan Green for help with the Windows part.

There might be a few call sites that actually work around this bug that 
we can clean up.


cheers


andrew



--
Andrew Dunstan
EDB: https://www.enterprisedb.com

Attachment

pgsql-hackers by date:

Previous
From: Vitaly Davydov
Date:
Subject: Re: Deadlock detector fails to activate on a hot standby replica
Next
From: Andrew Dunstan
Date:
Subject: Re: Fix pg_restore --no-globals SQL output for pg_dumpall archives