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-19T15:07:58Z
Lists: pgsql-hackers

Attachments

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.

			regards, tom lane

Commits

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