Re: fix pg_mkdir_p to tolerate concurrent directory creation
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Álvaro Herrera <alvherre@kurilemu.de>
Cc: Andrew Dunstan <andrew@dunslane.net>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-06-19T14:51:02Z
Lists: pgsql-hackers
=?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
Commits
-
Make pg_mkdir_p() tolerant of a concurrent directory creation.
- f25a07b2d94c 19 (unreleased) landed
- f0a831ef3e68 17 (unreleased) landed
- aa80c34c85f4 18 (unreleased) landed
- 9951e3d382c6 16 (unreleased) landed
- 4b3bc6b71453 14 (unreleased) landed
- 4647ac14230d 15 (unreleased) landed