From: Álvaro Herrera <alvherre@kurilemu.de>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: fix pg_mkdir_p to tolerate concurrent directory creation
Date: Fri, 19 Jun 2026 16:01:47 +0200
Message-ID: <ajVLauHFakqDsXsY@alvherre.pgsql> (raw)
In-Reply-To: <3ca004de-e49b-4471-b8aa-fd656e70f68c@dunslane.net>
On 2026-Jun-18, Andrew Dunstan wrote:
>
> 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.
Hmm, should the 'break's in the loop be 'continue's? If you're creating
path a/b/c, and a concurrent process beats you but is only attempting to
do a/b, then with the break you'll fail to create the final c.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
Bob [Floyd] used to say that he was planning to get a Ph.D. by the "green
stamp method," namely by saving envelopes addressed to him as 'Dr. Floyd'.
After collecting 500 such letters, he mused, a university somewhere in
Arizona would probably grant him a degree. (Don Knuth)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@kurilemu.de, andrew@dunslane.net, pgsql-hackers@lists.postgresql.org
Subject: Re: fix pg_mkdir_p to tolerate concurrent directory creation
In-Reply-To: <ajVLauHFakqDsXsY@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox