From: Tom Lane <tgl@sss.pgh.pa.us>
To: Álvaro Herrera <alvherre@kurilemu.de>
Cc: 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 10:51:02 -0400
Message-ID: <1472098.1781880662@sss.pgh.pa.us> (raw)
In-Reply-To: <ajVLauHFakqDsXsY@alvherre.pgsql>
References: <ajVLauHFakqDsXsY@alvherre.pgsql>
=?utf-8?Q?=C3=81lvaro?= Herrera <alvherre@kurilemu.de> writes:
> 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.
Maybe I'm confused, but I think it's right as-is. The "break"s are
places where we're giving up and reporting a hard error. If we want
to continue to the next directory level, we just fall through ---
and doing that with "continue" would be wrong because it'd miss the
step at the bottom of the loop:
if (!last)
*p = '/';
regards, tom lane
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: tgl@sss.pgh.pa.us, 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: <1472098.1781880662@sss.pgh.pa.us>
* 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