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.94.2) (envelope-from ) id 1rs1Jo-004H6J-Ly for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Apr 2024 14:10:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rs1Jn-002cNe-E6 for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Apr 2024 14:10:23 +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.94.2) (envelope-from ) id 1rs1Jl-002cNW-U8 for pgsql-hackers@lists.postgresql.org; Wed, 03 Apr 2024 14:10:23 +0000 Received: from wfout1-smtp.messagingengine.com ([64.147.123.144]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rs1Jh-000Qo7-Rk for pgsql-hackers@lists.postgresql.org; Wed, 03 Apr 2024 14:10:21 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.west.internal (Postfix) with ESMTP id BD53A1C000F2; Wed, 3 Apr 2024 10:10:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 03 Apr 2024 10:10:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712153413; x= 1712239813; bh=y4Smf1yX22RimAJ40LQsg3a/Ddyv2BOFn3Tf67A27Qc=; b=M RE6ME9INnD32FN6d8trs/Z2t8NiYmUX+gocMjEyvPKIz0d1vfn2J85NXfmoYsuhN 7cd0h6Rcj0OG0xA84mhXjPkauqvwL1KGMezPiZj+hd/SXFvzpCOH4WR9h/2IJr8r nf1RQmZ3QDm0xd7dQHT9usk1gIGnC2pi5P39s7FZF/axkas4lxJ5ahkhDl0l5Xlh VS4z8h45nf0jVGNNJ4iJZuXJxpcMtyDzQsHJiFiY1fA/8Z53r6EZDDH2tC7enEbU e04mfAdmtMC36DJo2xr3ZSGgzKyfrHzrPOpX1IlK6DCU/qDoQmSuXx40RPiF0Vul FleAnK3VT/1MoolO6chIQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefiedgvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesmhekreertddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepudelkeekgfdttdettdekgfduvdeiffelteegjeeihfet heekveeftedtuddvhfeunecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 3 Apr 2024 10:10:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1712153408; bh=Z604DpDri74M71ks+hdSkVErH6r8eXP/Z6CdlEoD9ek=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Crh0rryJlEJ+aoYGKpq+oFGiUcYJ/Nh4bSc/a5cIUCqkEipVrUHwx/DcVwvKhXSlL EqZgvl0xGnDt/U7jK1HOxg1+FW8ap2uXg+OGDXko/uFDGje7S9kAPal9jlTG7G7LHU x2oBI9U/6sh5LJKIJNrhMQBdN5vQ0qqG9MdREG72SGNuc8QPzfycKSt54/UjF8Dkg3 nuIUjJSy9rCAtB2i3Q+MTeKoeOPfJLxSPpUHhCaO88du6dEWwm7AEHk0FsCITP1vS+ cbz1yaOsu6KPxKqSLPEUYVSUg6rAJNum/IjNgCSGNq2i8NsphFKldM1WfeZz5yQJi8 mMm7Vl728BkRg== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id EE68D41E; Wed, 3 Apr 2024 16:10:08 +0200 (CEST) Date: Wed, 3 Apr 2024 16:10:08 +0200 From: Alvaro Herrera To: Alexander Lakhin Cc: "Andrey M. Borodin" , Dilip Kumar , tender wang , PostgreSQL Hackers , Tomas Vondra Subject: Re: SLRU optimization - configurable buffer pool and partitioning the SLRU lock Message-ID: <202404031410.4salwbtgsw5q@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="pxdmo7hkizgm2kv2" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2a25eaf4-a3a4-5fd1-6241-9d7c73142085@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --pxdmo7hkizgm2kv2 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hello, On 2024-Apr-03, Alexander Lakhin wrote: > I've managed to trigger an assert added by 53c2a97a9. > Please try the following script against a server compiled with > -DTEST_SUMMARIZE_SERIAL (initially I observed this failure without the > define, it just simplifies reproducing...): Ah yes, absolutely, we're missing to trade the correct SLRU bank lock there. This rewrite of that small piece should fix it. Thanks for reporting this. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "Pido que me den el Nobel por razones humanitarias" (Nicanor Parra) --pxdmo7hkizgm2kv2 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Fix-zeroing-of-pg_serial-page-without-SLRU-bank-lock.patch" From 44c39cf4bf258fb0b65aa1acc5f84e5d7f729eb1 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 3 Apr 2024 16:00:24 +0200 Subject: [PATCH] Fix zeroing of pg_serial page without SLRU bank lock --- src/backend/storage/lmgr/predicate.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 3f378c0099..d5bbfbd4c6 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -137,7 +137,7 @@ * SerialControlLock * - Protects SerialControlData members * - * SerialSLRULock + * SLRU per-bank locks * - Protects SerialSlruCtl * * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group @@ -908,20 +908,25 @@ SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo) if (isNewPage) serialControl->headPage = targetPage; - LWLockAcquire(lock, LW_EXCLUSIVE); - if (isNewPage) { - /* Initialize intervening pages. */ - while (firstZeroPage != targetPage) + /* Initialize intervening pages; might involve trading locks */ + for (;;) { - (void) SimpleLruZeroPage(SerialSlruCtl, firstZeroPage); + lock = SimpleLruGetBankLock(SerialSlruCtl, firstZeroPage); + LWLockAcquire(lock, LW_EXCLUSIVE); + slotno = SimpleLruZeroPage(SerialSlruCtl, firstZeroPage); + if (firstZeroPage == targetPage) + break; firstZeroPage = SerialNextPage(firstZeroPage); + LWLockRelease(lock); } - slotno = SimpleLruZeroPage(SerialSlruCtl, targetPage); } else + { + LWLockAcquire(lock, LW_EXCLUSIVE); slotno = SimpleLruReadPage(SerialSlruCtl, targetPage, true, xid); + } SerialValue(slotno, xid) = minConflictCommitSeqNo; SerialSlruCtl->shared->page_dirty[slotno] = true; -- 2.39.2 --pxdmo7hkizgm2kv2--