Re: fix pg_mkdir_p to tolerate concurrent directory creation

Andrew Dunstan <andrew@dunslane.net>

From: Andrew Dunstan <andrew@dunslane.net>
To: Tom Lane <tgl@sss.pgh.pa.us>, Álvaro Herrera <alvherre@kurilemu.de>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-06-19T15:40:52Z
Lists: pgsql-hackers
On 2026-06-19 Fr 11:07 AM, Tom Lane wrote:
> Actually ... given this change, why don't we drop the initial stat()
> call?  Just try mkdir(), and move on if it succeeds.  If not, but
> there's already a directory there, we're good.  That eliminates the
> race condition without duplicating code.


LGTM, thanks!


cheers


andrew


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




Commits

  1. Make pg_mkdir_p() tolerant of a concurrent directory creation.