Re: File locks for data directory lockfile in the context of Linux namespaces

From: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
To: Ilmar Yunusov <tanswis42(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: File locks for data directory lockfile in the context of Linux namespaces
Date: 2026-06-23 14:29:41
Message-ID: xhzl7ll7fwmlecg4htsgvr3fcwcec4cvugqebphofvcz4srkkn@vpwa2zgswuwy
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Fri, Jun 19, 2026 at 05:11:11PM +0200, Dmitry Dolgov wrote:
> > Is locking the socket lock file intentional here? If so, maybe the helper name,
> > comment, and fd tracking should reflect that broader scope. If not, perhaps the
> > new lock should be applied only for the isDDLock case; otherwise v2 changes
> > socket lockfile semantics too, not only postmaster.pid.
>
> It's been a while, quite frankly I don't remember. On the face of it, I
> think both the directory and socket lock files should be locked in the
> same way, since both are equally susceptible for the failure scenario
> described in this thread, even if the consequences of a failure are
> different. Let me do some renaming to clarify that.
>
> > While reading that code, I also noticed a small error-path issue: DataDirLockFD
> > starts as 0, but if fcntl(F_OFD_SETLK) fails with a non-EAGAIN error the code
> > only emits a warning and does not assign a duplicate fd. UnlinkLockFiles()
> > then closes DataDirLockFD unconditionally. Initializing it to -1, closing it
> > conditionally, and checking dup(fd) would make that path more explicit.
>
> Good point, I'll address this in the next version.

Something like this should be sufficient I think.

Attachment Content-Type Size
v3-0001-Use-open-file-description-locks-for-lockfiles.patch text/plain 12.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christophe Pettus 2026-06-23 15:03:38 Re: The PostgreSQL C Dialect
Previous Message Henson Choi 2026-06-23 14:28:39 Re: Row pattern recognition