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 15:07:58
Message-ID: 1528024.1781881678@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v3-0001-Make-pg_mkdir_p-tolerant-of-a-concurrent-director.patch text/x-diff 1.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dmitry Dolgov 2026-06-19 15:11:11 Re: File locks for data directory lockfile in the context of Linux namespaces
Previous Message Tom Lane 2026-06-19 14:51:02 Re: fix pg_mkdir_p to tolerate concurrent directory creation