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 1lAxqh-0004cL-Dn for pgsql-hackers@arkaria.postgresql.org; Sat, 13 Feb 2021 16:32:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lAxqe-0002i9-Hx for pgsql-hackers@arkaria.postgresql.org; Sat, 13 Feb 2021 16:32:44 +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 1lAxqe-0002i1-Ag for pgsql-hackers@lists.postgresql.org; Sat, 13 Feb 2021 16:32:44 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lAxqb-0001vJ-W3 for pgsql-hackers@postgresql.org; Sat, 13 Feb 2021 16:32:43 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 518635E6; Sat, 13 Feb 2021 11:32:39 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sat, 13 Feb 2021 11:32:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=CECqV9QVZnifJIbcHKf87B9MJph ISfZ9CQnGy2aucR0=; b=oOCzFjkc4U6rPyoOmNXSUs/vPFEe7UTQykFU3kli+kl 3jyYphh1eLyQdJ8TR5ZTZ48eGf4ugWXDyBs+Mp0IXgDvR+cCRig7Rta1rvdX/0hx C2lfSdNYLcY0UgcXuYW1qrl8DRPgZR1CUoautPkaYyUmNyA0XRgL+wbmPeBC6AOS NiX+at0viVaoL2U/AjcursOdGLMHVBLaG85m6wENsO/Q7GpIiDlKjG+yocbxVY3r Ty+fuH7bafcHwQe6mEp/R61z3H7W2eWdE/TMZ2cf6GHaFvJWT0VS7aUsvrKCloqR 3hMJoEdDn2NVkmOfQPu8jmOq0G40dwGTBBMuv85Cw/w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=CECqV9 QVZnifJIbcHKf87B9MJphISfZ9CQnGy2aucR0=; b=ulfUTocc4Pwjcd33JKWC0W 8Z4Nv0BXL+dKuS1r8zAq1qUEGP/a+d8mZOxkVCx3gd19I8/dfExZqM5tU9H/xW4i PSfqzoK5RXuEx2EN8dNa1oLfn83QFlrBz8XxFYV73rphq3QcjrfWI0mPpruUzWrt GnkWcAP/EJmA0YM7QdWJMZJPyaR245TvlcORZhrNAkR9IzE7EZ9ui8HcbnMr39vl GAtQM2glgG8ficlXX0FLdg5Qw3ZktzonpjPYsztB+DZUZwIFu5SqoiILcdLk0ISY lx5TZkUXv11ta5AJliWZkBC1Fk++6L0Fx2Kl+YhyjfCfKQLHnsE0DmqMGeHR4zoA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrieefgdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepudekhfekleeugeevteehleffffejgeelueduleeffeeutdelffeujeffhfeu ffdunecukfhppeeijedrudeitddrvddujedrvdehtdenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgiivghlrdgu vg X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-217-250.hsd1.ca.comcast.net [67.160.217.250]) by mail.messagingengine.com (Postfix) with ESMTPA id 72BCA24005E; Sat, 13 Feb 2021 11:32:38 -0500 (EST) Date: Sat, 13 Feb 2021 08:32:37 -0800 From: Andres Freund To: Amit Kapila Cc: Robert Haas , Ashutosh Bapat , Ashutosh Bapat , Markus Wanner , pgsql-hackers , Ajin Cherian , Simon Riggs , Petr Jelinek Subject: Re: repeated decoding of prepared transactions Message-ID: <20210213163237.wuujppnhoygomool@alap3.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2021-02-10 08:02:17 +0530, Amit Kapila wrote: > On Wed, Feb 10, 2021 at 12:08 AM Robert Haas wrote: > > > > On Tue, Feb 9, 2021 at 6:57 AM Amit Kapila wrote: > > > I think similar happens without any of the work done in PG-14 as well > > > if we restart the apply worker before the commit completes on the > > > subscriber. After the restart, we will send the start_decoding_at > > > point based on some previous commit which will make publisher send the > > > entire transaction again. I don't think restart of WAL sender or WAL > > > receiver is such a common thing. It can only happen due to some bug in > > > code or user wishes to stop the nodes or some crash happened. > > > > Really? My impression is that the logical replication protocol is > > supposed to be designed in such a way that once a transaction is > > successfully confirmed, it won't be sent again. Now if something is > > not confirmed then it has to be sent again. But if it is confirmed > > then it shouldn't happen. Correct. > If by successfully confirmed, you mean that once the subscriber node > has received, it won't be sent again then as far as I know that is not > true. We rely on the flush location sent by the subscriber to advance > the decoding locations. We update the flush locations after we apply > the transaction's commit successfully. Also, after the restart, we use > the replication origin's last flush location as a point from where we > need the transactions and the origin's progress is updated at commit > time. That's not quite right. Yes, the flush location isn't guaranteed to be updated at that point, but a replication client will send the last location they've received and successfully processed, and that has to *guarantee* that they won't receive anything twice, or miss something. Otherwise you've broken the protocol. Greetings, Andres Freund