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 1sk7Vx-007r7g-86 for pgsql-committers@arkaria.postgresql.org; Fri, 30 Aug 2024 19:42:33 +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 1sk7Vu-009eJz-JI for pgsql-committers@arkaria.postgresql.org; Fri, 30 Aug 2024 19:42:31 +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 1sk7Vt-009e8f-4n for pgsql-committers@lists.postgresql.org; Fri, 30 Aug 2024 19:42:30 +0000 Received: from fhigh2-smtp.messagingengine.com ([103.168.172.153]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sk7Vo-002IMY-A9 for pgsql-committers@lists.postgresql.org; Fri, 30 Aug 2024 19:42:28 +0000 Received: from phl-compute-04.internal (phl-compute-04.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id BDA5011400A3; Fri, 30 Aug 2024 15:42:22 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Fri, 30 Aug 2024 15:42:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1725046942; x=1725133342; bh=GkPQCTO9GnyOVk1ie6oQ6MBKOJFrrO2+Ux1QQJzKLwU=; b= lWhPqY92kdEuAbSOl0k0V81XzbYffAfavenTZvDF3vMWsLcu7rf2h2ST+BOzBB5t 9ztS1O/DacVHADMHzwXzY3gQ435JDYknEWum5SSygVo3G4vdc36HTYUrLHwxHyj8 nfj2yBEN2vhGB//eYYrozqcR5YGsQ+FQpFtPdPlyVxU5wGiXQzhLamNTwYK0Fmnw KPO4NSkvUkzjA0/u9O7h7zCREsaXwchbmGwepUVmTYDwYNEn21KgO3SXl9B9jDpH cQmW3d4WXt/a+xeemoo/Auecn2pPHBfvKdTW2/nWfDlSGtHS6wCLcZPbipN14Zvf zYSqrFGL3PN2grVSEog/yg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1725046942; x= 1725133342; bh=GkPQCTO9GnyOVk1ie6oQ6MBKOJFrrO2+Ux1QQJzKLwU=; b=d /RnyEMgJCzqTQsltsVIzm1O87s8TRMQ6o1MDp9a7SN2AWZpubxFvOfJNmAANBoSz Jgdm4MffcPeiN6i7DTX62/6WosP0VgEMVyKOWqdPm2wwZYK9Vy8o/3cksNSTiPGc chHQgnnLJIRX8XyidXI6tV2oK/TLECbg0cHL+8VuzcNdqyeLegfiy40XYtpKdo++ F9ytRr7mA4YivHOzUGKXmANoGHy5+2o/fitYOuq9dmnmWrICZ3eL/4kdKfygY3Nv Jzw+JSJi09DF1JtDPGKtQgIy4chbgHCP71hCwxwsK/n8VMjP8WmZewEm788pLVJ7 GvFp8Mp2vyLW1xwnVQ+1Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudefiedgudeflecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtjeertddtvdej necuhfhrohhmpefrvghtvghrucfgihhsvghnthhrrghuthcuoehpvghtvghrsegvihhsvg hnthhrrghuthdrohhrgheqnecuggftrfgrthhtvghrnhepleeuveeuveeiveffledtkeeu ffevveffhfejudffvedtheeileejgefgveefveefnecuffhomhgrihhnpehpohhsthhgrh drvghspdhpohhsthhgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrsegvihhsvghnthhrrghuthdrohhrgh dpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheprghk ohhrohhtkhhovhesphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepphhgshhqlh dqtghomhhmihhtthgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 30 Aug 2024 15:42:21 -0400 (EDT) Message-ID: <18c0fa64-0475-415e-a1bd-665d922c5201@eisentraut.org> Date: Fri, 30 Aug 2024 21:42:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pgsql: Implement pg_wal_replay_wait() stored procedure To: Alexander Korotkov , pgsql-committers@lists.postgresql.org References: Content-Language: en-US From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 02.08.24 20:22, Alexander Korotkov wrote: > Implement pg_wal_replay_wait() stored procedure Why is this under src/backend/command/? Wouldn't it belong under src/backend/utils/adt/? > pg_wal_replay_wait() is to be used on standby and specifies waiting for > the specific WAL location to be replayed. This option is useful when > the user makes some data changes on primary and needs a guarantee to see > these changes are on standby. > > The queue of waiters is stored in the shared memory as an LSN-ordered pairing > heap, where the waiter with the nearest LSN stays on the top. During > the replay of WAL, waiters whose LSNs have already been replayed are deleted > from the shared memory pairing heap and woken up by setting their latches. > > pg_wal_replay_wait() needs to wait without any snapshot held. Otherwise, > the snapshot could prevent the replay of WAL records, implying a kind of > self-deadlock. This is why it is only possible to implement > pg_wal_replay_wait() as a procedure working without an active snapshot, > not a function. > > Catversion is bumped. > > Discussion: https://postgr.es/m/eb12f9b03851bb2583adab5df9579b4b%40postgrespro.ru > Author: Kartyshov Ivan, Alexander Korotkov > Reviewed-by: Michael Paquier, Peter Eisentraut, Dilip Kumar, Amit Kapila > Reviewed-by: Alexander Lakhin, Bharath Rupireddy, Euler Taveira > Reviewed-by: Heikki Linnakangas, Kyotaro Horiguchi > > Branch > ------ > master > > Details > ------- > https://git.postgresql.org/pg/commitdiff/3c5db1d6b01642bcd8dbf5e34b68f034365747bb > > Modified Files > -------------- > doc/src/sgml/func.sgml | 117 ++++++++ > src/backend/access/transam/xact.c | 6 + > src/backend/access/transam/xlog.c | 7 + > src/backend/access/transam/xlogrecovery.c | 11 + > src/backend/catalog/system_functions.sql | 3 + > src/backend/commands/Makefile | 3 +- > src/backend/commands/meson.build | 1 + > src/backend/commands/waitlsn.c | 363 ++++++++++++++++++++++++ > src/backend/lib/pairingheap.c | 18 +- > src/backend/storage/ipc/ipci.c | 3 + > src/backend/storage/lmgr/proc.c | 6 + > src/backend/tcop/pquery.c | 9 +- > src/backend/utils/activity/wait_event_names.txt | 2 + > src/include/catalog/catversion.h | 2 +- > src/include/catalog/pg_proc.dat | 6 + > src/include/commands/waitlsn.h | 80 ++++++ > src/include/lib/pairingheap.h | 3 + > src/include/storage/lwlocklist.h | 1 + > src/test/recovery/meson.build | 1 + > src/test/recovery/t/043_wal_replay_wait.pl | 150 ++++++++++ > src/tools/pgindent/typedefs.list | 2 + > 21 files changed, 786 insertions(+), 8 deletions(-) >