Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pXgFL-0000Cm-HF for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Mar 2023 10:33:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pXgFK-0007PM-B5 for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Mar 2023 10:33:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pXgFK-0007PD-1L for pgsql-hackers@lists.postgresql.org; Thu, 02 Mar 2023 10:33:10 +0000 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pXgFG-000505-U3 for pgsql-hackers@lists.postgresql.org; Thu, 02 Mar 2023 10:33:09 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id CF96F2B076BC; Thu, 2 Mar 2023 05:33:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 02 Mar 2023 05:33:04 -0500 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:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1677753183; x= 1677760383; bh=PLJb6xSVBp/wOZeQJhS8KR7qN3tpWTkQpIx6Ft2SoWk=; b=A iM5XAxINsfLqa2DCeSrt4PYeokyrtoRn6y2cTQgSBuYtYdJxEJKGiF//DcwQNGoP LShTw/uMdvbD6i5oITIYpWE03xyg08/TkDgkX9zJlbBbrlz5fqDyxl1ZCiQ/K+/7 qHJanFhTCdROCc6Jd9g6/iMFPcVSVCLEOTU2LEBIJJV330b0UzEuHLqBboqGRy+D LfX1HARs+XAfhDVMdbz1tGTccCKxM+MCrCG0CXJ4VXchGgXU0p7Wxr+2ZucqtKe6 /3cOL0F7QbJ6EpBZXdIJJCPFzxr1mXcaMfPZodVvIMhIla+ta0HlY/cc6RzfY+OI nB1YufTvJNobQH7I4mS6Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudeljedgudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheprfgvthgv rhcugfhishgvnhhtrhgruhhtuceophgvthgvrhdrvghishgvnhhtrhgruhhtsegvnhhtvg hrphhrihhsvggusgdrtghomheqnecuggftrfgrthhtvghrnhepffeigeetvdeitdejteeu feethfelffetleefieeugfefieetudfhhffhkeduueffnecuffhomhgrihhnpehpohhsth hgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghuthesvghnthgvrhhprhhishgvug gsrdgtohhm X-ME-Proxy: Feedback-ID: i131946ab:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 2 Mar 2023 05:33:02 -0500 (EST) Message-ID: <8b5b172f-0ae7-d644-8358-e2851dded43b@enterprisedb.com> Date: Thu, 2 Mar 2023 11:33:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [HACKERS] make async slave to wait for lsn to be replayed Content-Language: en-US To: Kartyshov Ivan , pgsql-hackers@lists.postgresql.org References: From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 28.02.23 11:10, Kartyshov Ivan wrote: > 3) Procedure style: Tom Lane and Kyotaro (wait_proc_v1.patch) > https://www.postgresql.org/message-id/27171.1586439221%40sss.pgh.pa.us > https://www.postgresql.org/message-id/20210121.173009.235021120161403875.horikyota.ntt%40gmail.com > ========== > advantages: no new words in grammar,like it made in > pg_last_wal_replay_lsn, no snapshots need > disadvantages: a little harder to remember names > SELECT pg_waitlsn(‘LSN’, timeout); > SELECT pg_waitlsn_infinite(‘LSN’); > SELECT pg_waitlsn_no_wait(‘LSN’); Of the presented options, I prefer this one. (Maybe with a "_" between "wait" and "lsn".) But I wonder how a client is going to get the LSN. How would all of this be used by a client? I can think of a scenarios where you have an application that issues a bunch of SQL commands and you have some kind of pooler in the middle that redirects those commands to different hosts, and what you really want is to have it transparently behave as if it's just a single host. Do we want to inject a bunch of "SELECT pg_get_lsn()", "SELECT pg_wait_lsn()" calls into that? I'm tempted to think this could be a protocol-layer facility. Every query automatically returns the current LSN, and every query can also send along an LSN to wait for, and the client library would just keep track of the LSN for (what it thinks of as) the connection. So you get some automatic serialization without having to modify your client code. That said, exposing this functionality using functions could be a valid step in that direction, so that you can at least build out the actual internals of the functionality and test it out.