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 1r9rAn-002nSv-RJ for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Dec 2023 18:26:33 +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 1r9rAj-00D883-OB for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Dec 2023 18:26:29 +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 1r9rAj-00D87t-DA for pgsql-hackers@lists.postgresql.org; Sun, 03 Dec 2023 18:26:29 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r9rAb-009vAN-GI for pgsql-hackers@lists.postgresql.org; Sun, 03 Dec 2023 18:26:28 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40b27726369so38662565e9.0 for ; Sun, 03 Dec 2023 10:26:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1701627978; x=1702232778; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=zAP27S81gK2BK/qGRBi5yqaT1L1ee+/ud8ZgWj8R0L8=; b=l35q9RmN/mL3pb7DC/ZpywxRXmhfXWlLRWPNPJws+rR0ixNRsTCsoMOND+Bjon0O1L UTI2/UZANnu6gwUFniliwHvqZeVmIKaKk6Q3iE8v7ICfSelwgzya9+cZmGVCp8MIkpFO R1XFZXNTgOBGqelmn4E8QP1o1zkpULl03Q6+0SSxHf7LhqAyPt9F+vKzxRhC9+s6Iy0i 7EpA74PSXSLnTyZbzTkcxACyPWiacw70Gw0dG5TlG3xCPEnvf7EId08FtuemsqNahyFn mhX/Xv0WCX32JvAxYIvKusgySzDAc9AStK6hQUfPusd+kdPG8WQIfMJtBVP4356K0Qrp 30NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701627978; x=1702232778; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zAP27S81gK2BK/qGRBi5yqaT1L1ee+/ud8ZgWj8R0L8=; b=OCfjMxxFB6frHWsHnRK4tsfoYaOAezKMjJX5iCdH8LHhtS2RfSV6k4gLPkS+G3K3rf LoJz5W0F2ZklANGDnffjq8rExzGlXVlpMqM1WTkmUBShfQz1ypta1f3KyWSuQKkLDrh/ jD0lxB1iDpvxDM/GVmbpmBufVPy6S/ZUptApmwLPKbzm7tQFHEk+0AbqV4vCYMmLNXXM 5tnN3WDLel6Cj3EzwOzJ80Pq2WI3zu28O9v5mlmMX1ZnKxysp6rfqnsPWLiU5vYwyCrG sx12NJZxg3rSmx6kL4nDG4/yLaqXYfYixZbwxqIFKIhv/Wz6FNVHwyyve+8oxAU9U8UV qRkQ== X-Gm-Message-State: AOJu0YyAIFWtpK+R7Sjzf8x8J0fwkAKOmiQwM6dYwpbdqWOxuXglwXOD RSAePwkdQoTYD5RD7HpKkX2B1A== X-Google-Smtp-Source: AGHT+IHwfrWcMWOtFabZg8Ae/3kD77dF4oJa5KNt4pQecIHbJyBYc+EpEIdH2vep4JOYzfpsDXEtpQ== X-Received: by 2002:a1c:7917:0:b0:40b:5e21:e280 with SMTP id l23-20020a1c7917000000b0040b5e21e280mr1774515wme.109.1701627978602; Sun, 03 Dec 2023 10:26:18 -0800 (PST) Received: from [10.137.0.17] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id j35-20020a05600c1c2300b004076f522058sm16150262wms.0.2023.12.03.10.26.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 03 Dec 2023 10:26:18 -0800 (PST) Message-ID: <44abc443-3266-0227-4d45-4dacadd4cec9@enterprisedb.com> Date: Sun, 3 Dec 2023 19:26:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: logical decoding and replication of sequences, take 2 Content-Language: en-US From: Tomas Vondra To: "Hayato Kuroda (Fujitsu)" , Amit Kapila Cc: "Zhijie Hou (Fujitsu)" , Ashutosh Bapat , PostgreSQL Hackers , Masahiko Sawada , Peter Eisentraut , Dilip Kumar References: <36f3a200-f185-887c-da08-fdc866436e6c@enterprisedb.com> <195be236-7580-72c6-97c7-59f06c4e093c@enterprisedb.com> <4954a4f8-ba9d-d352-571b-7b94372ea5ae@enterprisedb.com> <418ff5ac-1664-9038-8ac6-0dd308b5df07@enterprisedb.com> <8a2f25d8-23d4-4ab8-2a23-7c8d2d976209@enterprisedb.com> In-Reply-To: <8a2f25d8-23d4-4ab8-2a23-7c8d2d976209@enterprisedb.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/3/23 18:52, Tomas Vondra wrote: > ... > > Some time ago I floated the idea of maybe "queuing" the sequence changes > and only replay them on the next commit, somehow. But we did ran into > problems with which snapshot to use, that I didn't know how to solve. > Maybe we should try again. The idea is we'd queue the non-transactional > changes somewhere (can't be in the transaction, because we must keep > them even if it aborts), and then "inject" them into the next commit. > That'd mean we wouldn't do the separate start/abort for each change. > Another idea is that maybe we could somehow inform ReorderBuffer whether the output plugin even is interested in sequences. That'd help with cases where we don't even want/need to replicate sequences, e.g. because the publication does not specify (publish=sequence). What happens now in that case is we call ReorderBufferQueueSequence(), it does the whole dance with starting/aborting the transaction, calls rb->sequence() which just does "meh" and doesn't do anything. Maybe we could just short-circuit this by asking the output plugin somehow. In an extreme case the plugin may not even specify the sequence callbacks, and we're still doing all of this. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company