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 1wRoAG-002idC-2i for pgsql-bugs@arkaria.postgresql.org; Tue, 26 May 2026 09:33:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wRoAD-0048Qm-25 for pgsql-bugs@arkaria.postgresql.org; Tue, 26 May 2026 09:33:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wRoAD-0048Qd-0i for pgsql-bugs@lists.postgresql.org; Tue, 26 May 2026 09:33:30 +0000 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wRoAB-00000001UmT-42GG for pgsql-bugs@lists.postgresql.org; Tue, 26 May 2026 09:33:29 +0000 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 4CD5C8074E; Tue, 26 May 2026 12:33:25 +0300 (MSK) Received: from smtpclient.apple (unknown [2a02:6bf:8080:d4f::1:24]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp) with ESMTPSA id NXUgXR1gFiE0-89GPsKTt; Tue, 26 May 2026 12:33:24 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1779788004; bh=a1SRia5Mr64SXIoIH4M+qRrmEAX9eDAbJ4w6v93UQCY=; h=References:To:Cc:In-Reply-To:Date:From:Message-Id:Subject; b=fN6JtMw4B8LIw1y3RIvDlEJxGQPRmLFp4F0TBRIrw9F4GxfsRuHPahdIY0MOGQxPI hDlS30wbhxmYVwjDazHjFGthk3iMt5XY+rpCDvkJQPIzD619pJdoKUB4ZEi4GXC83c XUAP409AZ1ejG1AYCbalTA4gY7AlEbAcASI/uN1M= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Andrey Borodin Message-Id: <9DF05C0C-D165-4821-80C2-FFAF47C07FF4@yandex-team.ru> Content-Type: multipart/mixed; boundary="Apple-Mail=_49D10CFB-0EC0-492E-BCF3-A527712C4438" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: BUG #19490: Streaming standby on 16.14 stops applying WAL on MultiXactOffsetSLRU when primary is 16.8 Date: Tue, 26 May 2026 14:33:11 +0500 In-Reply-To: Cc: Ayush Tiwari , Radim Marek , Heikki Linnakangas , Marko Tiikkaja , PostgreSQL mailing lists To: Michael Paquier References: <19490-9c59c6a583513b99@postgresql.org> <46FE61C9-F273-45FD-BED7-0F8CDA6EB992@yandex-team.ru> <46DB3CAB-EA1C-41A5-9D6D-5F913A2AAF66@yandex-team.ru> X-Mailer: Apple Mail (2.3864.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_49D10CFB-0EC0-492E-BCF3-A527712C4438 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii > On 26 May 2026, at 14:27, Michael Paquier wrote: > > Hmm, okay. I am not sure what you mean here, could you demonstrate > your idea with a patch later? Something like attached, not tested yet, working on an automated test. Best regards, Andrey Borodin. --Apple-Mail=_49D10CFB-0EC0-492E-BCF3-A527712C4438 Content-Disposition: attachment; filename=demo.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="demo.diff" Content-Transfer-Encoding: 7bit diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index f825579e888..8899d5ac63d 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -888,8 +888,6 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, MultiXactOffset *next_offptr; MultiXactOffset next_offset; - LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE); - /* position of this multixid in the offsets SLRU area */ pageno = MultiXactIdToOffsetPage(multi); entryno = MultiXactIdToOffsetEntry(multi); @@ -907,6 +905,9 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, * multixid was assigned. If we're replaying WAL that was generated by * such a version, the next page might not be initialized yet. Initialize * it now. + * + * This block runs before acquiring MultiXactOffsetSLRULock because + * SimpleLruWriteAll() needs to acquire the same lock internally. */ if (InRecovery && next_pageno != pageno) { @@ -951,6 +952,8 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, { elog(DEBUG1, "next offsets page is not initialized, initializing it now"); + LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE); + /* Create and zero the page */ slotno = SimpleLruZeroPage(MultiXactOffsetCtl, next_pageno); @@ -958,6 +961,8 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, SimpleLruWritePage(MultiXactOffsetCtl, slotno); Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]); + LWLockRelease(MultiXactOffsetSLRULock); + /* * Remember that we initialized the page, so that we don't zero it * again at the XLOG_MULTIXACT_ZERO_OFF_PAGE record. @@ -967,6 +972,8 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, } } + LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE); + /* * Set the starting offset of this multixid's members. * --Apple-Mail=_49D10CFB-0EC0-492E-BCF3-A527712C4438--