Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wc28N-0032ML-1P for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jun 2026 14:29:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wc28M-00CUCO-0a for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jun 2026 14:29:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from <9erthalion6@gmail.com>) id 1wc28L-00CUCG-25 for pgsql-hackers@lists.postgresql.org; Tue, 23 Jun 2026 14:29:49 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from <9erthalion6@gmail.com>) id 1wc28J-00000001l2L-210T for pgsql-hackers@lists.postgresql.org; Tue, 23 Jun 2026 14:29:48 +0000 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-697df404e32so1023923a12.0 for ; Tue, 23 Jun 2026 07:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782224986; x=1782829786; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Nyh3m0b6GlTS4rCfo+BolEqmtXSfl7WWaMZsI6owURk=; b=qH6F9DZnyIhVr/s/v0CWEhRhFAlzCCxHVUymsjXs9ur9YXFviXl2Xk/7/Kd+hB0KC1 Ng9DhO0xHADs/tOqc+nUbZdnncnErSDQaCOxIN23fipq/MwSUAWtOc/8XTDCB7ce6q6I p50X27+h/XmBuPmAVc/j+iBTUBdnCZizak/F3Q0oBvIe4N8kAe15bzsR+05plJJh9agD 2+svnlczQrvqFgy4HrKTU6g7ohezsluo53IHEwm3+L1+MYdtbZDzAHMJwP13jvq0ZcHX l23g+c9PFG4Xfz9rY7ek9WXhJkSci8jDCuzS+VjdBtcPWS9/sVUoQo+EJDaKWgTgLPMN slzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782224986; x=1782829786; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nyh3m0b6GlTS4rCfo+BolEqmtXSfl7WWaMZsI6owURk=; b=Ohef0k0X1+tDRowZj7jxta5NSCx31OZzoeYXU/1XxGyEZ2BEBu7YQ7/1AV7GqQJm4g bjLvpAXVNOjwDS6A0Eq1FJtExS6AUCc6jPKWpTiJ57SspRYg5kk7DlMwk+TEeD7QKm+j mSKAGDtMI/OSWDb/GyyHhV0CjYFwjwI7TYki0bgvwDlkGPhS5ulnfwmYDyXFcNZapsMu RJKBKuoUpCuF4LahNqGqDvF133I9Het+w51g1w5IQmQxjVon9S427p77zuZXknfZJVKP +DKXslorJYdTRoDAYY2Wln8vSjTO7QaLyKXaoiuq8n+1T47iD6DQ59dlGwC8ddWv6td6 hSzw== X-Gm-Message-State: AOJu0Yw23juSHPtxgTGcw/uPoSrp1DMht5mbxrp1F+8gkskVbI99Cdad Wncxqd5D/MxTwm7NST3vPcI9JM2YMdPCwRhEaogbESzQdCD4OKAiRHvOATcbMQ== X-Gm-Gg: AfdE7ck6q02jb/ajoVhylYWKq5QduV1MdqP9QTJDkXiRbRW4S5ZDGimaJfPsFNdWFTo fgy6/Q+tinBaXLxswu+tnhCuhdBu37IoAfXnbduXf3l07QGlBkwCnoJ8cOKfAJLWGCmvZJ8JFpK De+mrOTYn123KSbX4hVwynqWFkEmWonIkCVEpW7PohuaHlJHIZSFMOYWKo2xgvx29t0UnPg8eHY TXmfkoeypkENMGGSFNbmcVlKvKJBc2WQpM3vA/HvbYSgUTBD3CAi2x2ECkwz22upNEqa7wkImDU feZeWwn3+DPz25DKH7+YB71jSjF5WlF+Z1/ZogJnspwL5aj/q3Y+ytpPGAKjamYqURVD//1Ddom sS/hwvcRSXD8OJn8v3mtwvHe9iOT4ZSpzxO29oGO/Y61ZnJlKWckbn9DQl79UKGi9crJH5nN+6e COpPcpOiPYkA79EqEvGH7pzyoQRQhO29//LndC1tnnnVfy68x93SEcHwcc5W6Jlgyq4sRzSpI5B vbcAe1Z1XIMb7H8HDDxXD2JZlkNk/l75BgPDLKX X-Received: by 2002:a05:6402:4316:b0:697:5140:a146 with SMTP id 4fb4d7f45d1cf-697dbad0f1dmr1872202a12.5.1782224985297; Tue, 23 Jun 2026 07:29:45 -0700 (PDT) Received: from ddolgov-thinkpadt14sgen1.rmtde.csb (dslb-092-077-218-103.092.077.pools.vodafone-ip.de. [92.77.218.103]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-697cf760eeesm1710044a12.15.2026.06.23.07.29.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2026 07:29:43 -0700 (PDT) Date: Tue, 23 Jun 2026 16:29:41 +0200 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Ilmar Yunusov Cc: pgsql-hackers@lists.postgresql.org Subject: Re: File locks for data directory lockfile in the context of Linux namespaces Message-ID: References: <45swup77t7utfy33lu47mvkb4exzm3oeakz25abqxuvmsyzt3c@5umrpfgc3ypg> <178066304625.594057.12185296716401427152.pgcf@coridan.postgresql.org> <54uh7vhavffktp72dmjm7ms26lntxacnvpwuaitiez4izugdi6@emwc2yrpqwk2> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="zdel3ow7bygx53fm" Content-Disposition: inline In-Reply-To: <54uh7vhavffktp72dmjm7ms26lntxacnvpwuaitiez4izugdi6@emwc2yrpqwk2> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --zdel3ow7bygx53fm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline > 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. --zdel3ow7bygx53fm Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v3-0001-Use-open-file-description-locks-for-lockfiles.patch"