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 1sQbkh-00Afch-Lj for pgsql-bugs@arkaria.postgresql.org; Sun, 07 Jul 2024 23:57:07 +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 1sQbkg-00GV4h-8g for pgsql-bugs@arkaria.postgresql.org; Sun, 07 Jul 2024 23:57:06 +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 1sQbkg-00GV4Z-05 for pgsql-bugs@lists.postgresql.org; Sun, 07 Jul 2024 23:57:06 +0000 Received: from fhigh6-smtp.messagingengine.com ([103.168.172.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sQbkZ-000xFD-7D for pgsql-bugs@lists.postgresql.org; Sun, 07 Jul 2024 23:57:05 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 15E33114028E; Sun, 7 Jul 2024 19:56:57 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 07 Jul 2024 19:56:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc: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=fm2; t=1720396617; x=1720483017; bh=aW914ugmZe zuS5C1mDR0U+upnemID45y7sHRewTM7XM=; b=hhxL87bbITYef44HP0JnVeMCfC V0rSGS5LJLAjpdq2r0oJ6dDmTWo7hjGSz9nKwblZ/CaqvSuuvQ0i+sN0h9djmUES n67XWL4b3dI1uFG0rsMHUingKJ7WSmt1absm1WheH32/UcyBVdtUGpQWwi24Vqxx FtWJEjjikamY6YRavZTs4anVKKxXCvoBY+K+8Xdk9XBMRoBPuMZuQFHza6WnpkWz Ugk5XKSqU6ToO5nPc+lKg/T3F27towS8A4JRTZy/vL1U7P02yKUDrQ9/LMZYfnd2 ri6CXqGPIejg4bMM/nTtfi7OT4yatYQlqqwFk9I2KessRUrE4hXqYAPz9EWQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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= fm2; t=1720396617; x=1720483017; bh=aW914ugmZezuS5C1mDR0U+upnemI D45y7sHRewTM7XM=; b=C7INs2+WVVoQPp7IpZIbOY8+5yC4lwR2D4dzHDVVocwp lsAWlbpAkU8jr3+Owh1Vt9hWtGYx2cpHHdTaB2sZEVmVfpCZTBHCP4MgDEm805Ld E0YP0Xk6wQFftObB7+JmpWRPsWydQRLON2uO3B19EvItoek4LTOgzX/He/kMZhKM mBMD/MLcN0BuwPkUBWQfL9iNValJUElLfvTRyo9I10q1YKfwFh1kRETLBUv24I1F jnoWLsEasdkC0TfEa8BBPkExoRxIDIuEAZRess3ReDAiY8RqLr3zPGCgTQH1Gk2e k6GCa4xwBToOhhYaekpzVIlwnOl+JT/S/HCA8Mm6xQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdeigddvlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeg geffhfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Jul 2024 19:56:54 -0400 (EDT) Date: Mon, 8 Jul 2024 08:56:42 +0900 From: Michael Paquier To: Masahiko Sawada Cc: Amit Kapila , "Callahan, Drew" , "pgsql-bugs@lists.postgresql.org" Subject: Re: Potential data loss due to race condition during logical replication slot creation Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Iwr6qlAw+Wfzqpqk" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Iwr6qlAw+Wfzqpqk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 05, 2024 at 11:52:52PM +0900, Masahiko Sawada wrote: > I've attached updated patches for HEAD and pg17 for now (I will create > the patch for other backbranches). >=20 > In the patches, I used a different approach in between HEAD and > backbranches. On HEAD, we store a flag indicating whether or not we > should skip snapshot restores into the SnapBuild struct and set it > only while finding the start point. Therefore we have to bump > SNAPBUILD_VERSION. On backbranches, I used the approach we discussed > above; store the flag in LogicalDecodingContext and set it when > creating the LogicalDecodingContext for a new logical slot. A possible > downside of the approach taken for backbranches is that we implicitly > require for users to use the same LogicalDecodingContext for both > initializing the context for a new slot and finding its start point. > IIUC it was not strictly required. This restriction would not be a > problem at least in the core, but I'm not sure if there are no > external extensions that create a logical slot in that way. This is > the main reason why I used a different approach on HEAD and > backbranches. Therefore, if it does not matter, I think we can use the > same approach on all branches, which is better in terms of > maintainability. --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -189,6 +189,9 @@ struct SnapBuild /* Indicates if we are building full snapshot or just catalog one. */ bool building_full_snapshot; =20 + /* Indicates if we are finding the start point to extract changes */ + bool finding_start_point; + FYI, I think that it is still OK to bump SNAPBUILD_VERSION on REL_17_STABLE. That will reduce by 1 year the time window required to maintain the tweaks implemented for the versions in the back-branches. So I'd suggest to do what the v17 version of the patch does for ~16, and use the snapshot format changes in 17~. -- Michael --Iwr6qlAw+Wfzqpqk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmaLKzoACgkQnvQgOdby QH21wQ//fEhkdkmvmWplbrNN8WeN5rfA/PiMSut0dk2mX/XlKvN3QvWRRtuBpSLl SssPY8NvZmubEzF1B5DCKZb7EB0dykb0SN1NLyUUdPAhI3ZxaSo8ZaDXq/XcbI+7 cpFsOz+PIyxsMeXoHAFVm1r0t5Oxw4cvvir2oKyg7qG9POq5Qw2jcOYFKijbWFYI jRYOk3aD5vwP2NyM5ikqPoR84ok6tUMstVLqptWZubHy9NsQnmVkiFSuIWuAKoIP efwmei6YPPeZho0+mxCzkOWizDImxZOlCI0tJMcOFuY7bFaIWICFxgex5s+tI2AB 6vywbEbUrAqfnWRG1gyouHd1H4TCRvw8fPbbP8EiR2bPG3Opf0bsZyKXb70/9Ion 1nbB21JdwJw2YlTH7FfEGVGWleD5O/SCkfEHkRe+MVNf/77eTzKWn2MqrOjGczeT EslOb1FfPBL84xF7NpGLRyrRRCXNtsMjX21abRCeWxidwQ7LfTvYKYFTg22+Au3T tnyuxfC7klDWfpCueWjkj3SYDVSAVjavUqbwerQBaBy+DBae84MBgJ58oMhgcGFz hYPmAbOfMzWpChnuftI7/wQ8+gNytu10WGZ3LQXaSSkWxBVXBxtTxsk6wN4LHJyN fXejsyvblNrDvQ4CRQNbzh7dGhmc6ZyZqFalscT0SNW9W1VQgYI= =cErJ -----END PGP SIGNATURE----- --Iwr6qlAw+Wfzqpqk--