Re: fix pg_mkdir_p to tolerate concurrent directory creation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: fix pg_mkdir_p to tolerate concurrent directory creation
Date: 2026-06-19 14:51:02
Message-ID: 1472098.1781880662@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

=?utf-8?Q?=C3=81lvaro?= Herrera <alvherre(at)kurilemu(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-06-19 15:07:58 Re: fix pg_mkdir_p to tolerate concurrent directory creation
Previous Message Fujii Masao 2026-06-19 14:15:52 Re: Fix publisher-side sequence permission reporting