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 1kT4aM-0003wP-AU for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Oct 2020 14:50:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kT4aK-0003vk-6m for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Oct 2020 14:50:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kT4aK-0003tl-0e for pgsql-bugs@lists.postgresql.org; Thu, 15 Oct 2020 14:50:28 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kT4aH-0001Ni-10 for pgsql-bugs@lists.postgresql.org; Thu, 15 Oct 2020 14:50:27 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id CBD865C01ED; Thu, 15 Oct 2020 10:50:23 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 15 Oct 2020 10:50:23 -0400 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=SHOt93QNlBeEKtQyG jS8/YjXoIQdqWfANrwauBKvFyM=; b=k57obMdk6V44rz5FPvnmYmdapKgn4/aVE LDrjNB5RTT7/ZfiDWTUqdk8P0SITkwTqoOIT0Ryngj2lIQblnRIagWxzAcA/xPbH jmV+RaFyTshfVPzXkH29GgLZW6Mo4ZKp3AqtKYy2RtMWLC2W5npS6qny/vOuz3gB 5ji9VHJfHpwe6WO8XctRRc+GZP/e/6ulDAmxG1k7C++CHtYtUKkFb58RoQImNRxZ zinQOtEeBJMISxxLY4jlu0bLgwtegsRzeJj9+cckM38rgstCV8McdXIiMkWmoTl8 NC2LtQh9FmEC/31ohGknrj5AV04jiUCXA1qNX4BnxgospUfQTRV5A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrieefgdektdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtuggjfgesthdtredttdervdenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepvefgleevgeeujeeghfegteeghfegheeifeehheelteetiedu ieeihffggfehffetnecukfhppeduledtrdelhedrudelrddugeeknecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhv hhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.148]) by mail.messagingengine.com (Postfix) with ESMTPA id 06EB93064687; Thu, 15 Oct 2020 10:50:23 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 5B1892A14E9; Thu, 15 Oct 2020 11:50:19 -0300 (-03) Date: Thu, 15 Oct 2020 11:50:19 -0300 From: Alvaro Herrera To: Petr Jelinek Cc: Tom Lane , Henry Hinze , pgsql-bugs@lists.postgresql.org, Peter Eisentraut Subject: Re: BUG #16643: PG13 - Logical replication - initial startup never finishes and gets stuck in startup loop Message-ID: <20201015145019.GA4779@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4a37c0e0-88a5-5d09-19c6-390b8412d3e6@2ndquadrant.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Oct-14, Petr Jelinek wrote: > It would be nice if the new sentences at the beginning of tablesync.c > started with uppercase, but that's about as nitpicky as I can be :) OK, fixed that :-) And pushed (to master only). There's one more change I added at the last minute, which is to remove the 'missing_ok' parameter of GetSubscriptionRelState. There are some other cosmetic changes, but nothing of substance. > > If I understand correcly, the early exit in tablesync.c is not saving *a > > lot* of time (we don't actually skip replaying any WAL), even if it's > > saving execution of a bunch of code. So I stand by my position that > > removing the code is better because it's clearer about what is actually > > happening. > > I don't really have any problems with the simplification you propose. The > saved time is probably in order of hundreds of ms which for table sync is > insignificant. Great, thanks. If you think this is done ... I have taken a few notes in the process: * STREAM COMMIT bug? In apply_handle_stream_commit, we do CommitTransactionCommand, but apparently in a tablesync worker we shouldn't do it. * process_syncing_tables_for_apply belongs not in tablesync.c (maybe worker.c?) * DropSubscription bug / logicalrep_find_workers DropSubscription believes that it's valid to get a list of workers, then kill them one by one. But this is racy since one worker could end for other reasons and be replaced by a worker to another subscription. This code should use a loop that restarts after killing each worker. * subscription_change_cb too coarse It seems that we should only reset "subscription valid" when *our* subscription is changed, not other subscriptions. Otherwise we read our own sub data far too often. * PostgresNode uses print where it should use Test::More's note()