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 1kaJAV-0002bE-3Z for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Nov 2020 13:49:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kaJAT-0003e0-OX for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Nov 2020 13:49:41 +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 1kaJAS-0003dH-SJ for pgsql-bugs@lists.postgresql.org; Wed, 04 Nov 2020 13:49:41 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kaJAP-0002l4-Ik for pgsql-bugs@lists.postgresql.org; Wed, 04 Nov 2020 13:49:40 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 290505C011B; Wed, 4 Nov 2020 08:49:35 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 04 Nov 2020 08:49:35 -0500 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:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=mjhcV3tURAOHKf8pi ZJfhYJ5L126TeQ7+krZwTs9w3I=; b=IlEggD5ZvAik3JePI2nZwtxmoyKCCOh9F 75n1kPBXnAZqBRWoB15TvjUWVBDwYghuQDdKUUlOAhF02FP5tHzLs542JKEzxB3S I3PEc8UiDNMa7xJXVKJmKbUdgk/E56+DlBp0U9hDHWf1W76or1Bt/TCj2N3+rI4r TRROnwY3xo2NBuyEn5mBRsiTFOEbhHXhKego8tNhdB6URZbANj0Elstyjmbs6dZw hkNy/VMHgMP/NMNvMpozT92RSHn7ygckoi0nKP9+5ZGmp0oxRWfI8J/Tcimvrtmd p7vKk2V9CQLSQzlhhMWBXnD8ptWLENmqdlG+/YBVs10EJJOdU0+gw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddthedgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggujggfsehmtderredtredvnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpeeigefhleeuudehgedtkeejheeuffdvudejgfetudeikeej hfdufeegfeeivdejteenucfkphepudeltddrleehrdduledrudegkeenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghl vhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.148]) by mail.messagingengine.com (Postfix) with ESMTPA id 823E4328038E; Wed, 4 Nov 2020 08:49:34 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id E81C42A14D1; Wed, 4 Nov 2020 10:49:31 -0300 (-03) Date: Wed, 4 Nov 2020 10:49:31 -0300 From: Alvaro Herrera To: Amit Kapila Cc: Petr Jelinek , Tom Lane , Henry Hinze , PostgreSQL mailing lists , Peter Eisentraut Subject: Re: BUG #16643: PG13 - Logical replication - initial startup never finishes and gets stuck in startup loop Message-ID: <20201104134931.GA6515@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="h31gzZEtNLTqOjlF" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --h31gzZEtNLTqOjlF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On 2020-Nov-04, Amit Kapila wrote: > On Thu, Oct 15, 2020 at 8:20 PM Alvaro Herrera wrote: > > * STREAM COMMIT bug? > > In apply_handle_stream_commit, we do CommitTransactionCommand, but > > apparently in a tablesync worker we shouldn't do it. > > In the tablesync stage, we don't allow streaming. See pgoutput_startup > where we disable streaming for the init phase. As far as I understand, > for tablesync we create the initial slot during which streaming will > be disabled then we will copy the table (here logical decoding won't > be used) and then allow the apply worker to get any other data which > is inserted in the meantime. Now, I might be missing something here > but if you can explain it a bit more or share some test to show how we > can reach here via tablesync worker then we can discuss the possible > solution. Hmm, okay, that sounds like there would be no bug then. Maybe what we need is just an assert in apply_handle_stream_commit that !am_tablesync_worker(), as in the attached patch. Passes tests. --h31gzZEtNLTqOjlF Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="assert.patch" diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 04684912de..09f246fc1f 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -949,6 +949,9 @@ apply_handle_stream_commit(StringInfo s) MemoryContext oldcxt; BufFile *fd; + /* We don't allow streaming in tablesync */ + Assert(!am_tablesync_worker()); + Assert(!in_streamed_transaction); xid = logicalrep_read_stream_commit(s, &commit_data); --h31gzZEtNLTqOjlF--