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 1mTLwu-0003Ca-L9 for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Sep 2021 10:27:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mTLwt-0006UU-GI for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Sep 2021 10:27:27 +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 1mTLwt-0006UM-7y for pgsql-hackers@lists.postgresql.org; Thu, 23 Sep 2021 10:27:27 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mTLwo-0003kf-NM for pgsql-hackers@lists.postgresql.org; Thu, 23 Sep 2021 10:27:26 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 7E2FE5C00F0; Thu, 23 Sep 2021 06:27:20 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 23 Sep 2021 06:27:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=fm3; bh=Ig8P0qmTngkfAR4U0A3JU5YHOoWzTMOshQi0Yb/zn rM=; b=GQRJCGb+DYibeQ/vls9RPYRBIPVXgespjDn6Dg3i9aC5utquZToo5cxjR 6aoHnEY/axj4pOZx5tT7fbhoZn3Ng7KqDlVNTz0m0+H3TCIhJlmAnfACzmbvWcEz W01HfDoCV59Oq2ZnTsZuXS/BttpF1MfPaVthUJrnNpdja+cZ+4kaaSjWg2Lv1MW1 xO8TiTc0+IipRQrr3C9BSfcvTbIoAOkmoG4G8lNda3ZDrJT2hNd8BKlSLf1U5qM3 cwThO2bt+pVYg1XTyYXQQHF/yHXASan/eePqGw8jXTfM2CCTCR27Dm85SzTQjZbO Jklul++IfvIJK/Xr7HO6KUYsk4cMg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeiledgvdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheprfgvthgv rhcugfhishgvnhhtrhgruhhtuceophgvthgvrhdrvghishgvnhhtrhgruhhtsegvnhhtvg hrphhrihhsvggusgdrtghomheqnecuggftrfgrthhtvghrnhepleevheehueeiudeiteei tdekueetleefteejffeiffdugedvffdvffdtiedvueeknecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhdrvghishgvnhhtrhgruhht segvnhhtvghrphhrihhsvggusgdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Sep 2021 06:27:19 -0400 (EDT) Subject: Re: logical decoding and replication of sequences To: Tomas Vondra , vignesh C Cc: PostgreSQL Hackers , Petr Jelinek References: <377c6fda-c3eb-7a69-e981-c77ae459c5db@enterprisedb.com> <5105c3ad-d726-fc22-1d09-514b6852a15e@enterprisedb.com> <3005299b-267d-8e4a-68a3-abdad3e96aba@enterprisedb.com> <3d6df331-5532-6848-eb45-344b265e0238@enterprisedb.com> From: Peter Eisentraut Message-ID: <482c10c1-b110-819f-b0e7-17549fa2f0dc@enterprisedb.com> Date: Thu, 23 Sep 2021 12:27:17 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <3d6df331-5532-6848-eb45-344b265e0238@enterprisedb.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 30.07.21 20:26, Tomas Vondra wrote: > Here's a an updated version of this patch - rebased to current master, > and fixing some of the issues raised in Peter's review. This patch needs an update, as various conflicts have arisen now. As was discussed before, it might be better to present a separate patch for just the logical decoding part for now, since the replication and DDL stuff has the potential to conflict heavily with other patches being discussed right now. It looks like cutting this patch in two should be doable easily. I looked through the test cases in test_decoding again. It all looks pretty sensible. If anyone can think of any other tricky or dubious cases, we can add them there. It's easiest to discuss these things with concrete test cases rather than in theory. One slightly curious issue is that this can make sequence values go backwards, when seen by the logical decoding consumer, like in the test case: + BEGIN + sequence: public.test_sequence transactional: 1 created: 1 last_value: 1, log_cnt: 0 is_called: 0 + COMMIT + sequence: public.test_sequence transactional: 0 created: 0 last_value: 33, log_cnt: 0 is_called: 1 + BEGIN + sequence: public.test_sequence transactional: 1 created: 1 last_value: 4, log_cnt: 0 is_called: 1 + COMMIT + sequence: public.test_sequence transactional: 0 created: 0 last_value: 334, log_cnt: 0 is_called: 1 I suppose that's okay, since it's not really the intention that someone is concurrently consuming sequence values on the subscriber. Maybe something for the future. Fixing that would require changing the way transactional sequence DDL updates these values, so it's not directly the job of the decoding to address this. A small thing I found: Maybe the text that test_decoding produces for sequences can be made to look more consistent with the one for tables. For example, in + BEGIN + sequence: public.test_table_a_seq transactional: 1 created: 1 last_value: 1, log_cnt: 0 is_called: 0 + sequence: public.test_table_a_seq transactional: 1 created: 0 last_value: 33, log_cnt: 0 is_called: 1 + table public.test_table: INSERT: a[integer]:1 b[integer]:100 + table public.test_table: INSERT: a[integer]:2 b[integer]:200 + COMMIT note how the punctuation is different.