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 1nXh9g-0000Z8-BW for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Mar 2022 10:26:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nXh9e-0000Kl-UW for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Mar 2022 10:26:50 +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 1nXh9e-0000Kc-9p for pgsql-hackers@lists.postgresql.org; Fri, 25 Mar 2022 10:26:50 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nXh9Z-00017H-Pl for pgsql-hackers@lists.postgresql.org; Fri, 25 Mar 2022 10:26:49 +0000 Received: by mail-ej1-x629.google.com with SMTP id bq8so459502ejb.10 for ; Fri, 25 Mar 2022 03:26:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=LdWcqg66X08yHlqIEtjxlDPHsSv6bSPWN5VhRuiEBIs=; b=FFRURQpFNixaB37rb7Kr/ch7oyzj7XKixiYvfbPgWJDSgMjnh8rc4eKkN/91jBFBBl le7vblBT1NugXI7RX7fkAF+T4MjvJQi5/194FJqAc333dbhwNACJsRRZmuMcJPkpuNf/ NS7Bz7X+ks3peEmIaPHu0bOnicw4R12eRf51phy4I/TJKmSX80CqGgBmzmq62sZ+pR6M VCjB2gjFbfS49yNRP7Nk64GNjcfnO4d7Wns/xgwWrm0Pr5HTf0F6PlTq6ra/yUnumJFh fvEQcIk4mhRwB5C/TJDK9uSAGAM4nbRW86N4o1yRgSkeGy25ouaquZDZ+NVpIuZsT23Y vSEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=LdWcqg66X08yHlqIEtjxlDPHsSv6bSPWN5VhRuiEBIs=; b=w0TB7q5vob+0sM53YTebVmpi5jfZfdTIngTMslNrdyI0iYB/NxSadKkEqd41OtFTy6 rkGmhFP4q9NR7ru4tINEoAV4VwLW0E0wSG+Ox8Ghhzs+F99O5Irn39MmEJOVa2q+PC9/ UZS889e+9gswt2q8RM0CD4ZaUycdFWf0So4W689+DxgYWkowvyMFvn02fgGzFSLMl7qp caHEOT3WcnoKh7l6S48wfd3DoZ0/IeoRavbcdb/jim7AjpN7dbUHc3tIfiEBtd5TXwMx N/RSn8N0kXUEgvH6miZlIamzqAhstwIiWRA7X29uTWQjRq0kzH2MnLaxawJBs7DOyWqf VKpg== X-Gm-Message-State: AOAM531jz/mMlCkAfqpqA790ScpcznfuWSMWvSZuK8dsKqMFSXh2757l aqUfHtwHUAvtLAwhWyAoeN+nsE99NNKMSimfxxAjujZH6+GGTO+q/gBYsFqq/s1VGVOOvV0teMG ZFCKWOyZ2nlO08Idb0wWbXv7R22ksRkl4M/Xpwp7SY9Pg4YEZjV6f5mqfWv01Svq9wFO1ruzWV7 zpMh+yJon1Bcuk69G4kPvLf+B10yKjhYaJAx23BMdheHSTS9iv1FpP X-Google-Smtp-Source: ABdhPJxOuGccSSE4I37OJ1vxQDp9i1j/6ktYuU/2AQpH0EHupGtBSssd+UXrheOiuU3yySZQH+YRLg== X-Received: by 2002:a17:906:19c6:b0:6ce:98a4:5ee6 with SMTP id h6-20020a17090619c600b006ce98a45ee6mr10718149ejd.567.1648204000877; Fri, 25 Mar 2022 03:26:40 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-251-241.net.upcbroadband.cz. [86.49.251.241]) by smtp.gmail.com with ESMTPSA id b12-20020a056402278c00b004195a50759fsm2643840ede.84.2022.03.25.03.26.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Mar 2022 03:26:40 -0700 (PDT) Message-ID: <9d7635f8-2402-e038-64da-cbc3732ce8cf@enterprisedb.com> Date: Fri, 25 Mar 2022 11:26:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: logical decoding and replication of sequences Content-Language: en-US To: Amit Kapila Cc: Petr Jelinek , Peter Eisentraut , PostgreSQL Hackers References: <9defb937-20a9-1d9f-6972-f1c4b4da4f73@enterprisedb.com> <8e766e0f-ed3e-fd68-4b0f-10dd2db60c88@enterprisedb.com> <6b21233e-c880-e4ad-5df2-7832f769296c@enterprisedb.com> <9da788c7-01eb-f11d-aa08-c5f61fe9f33a@enterprisedb.com> <456A528F-8F19-41C7-9857-927024D32396@enterprisedb.com> <74729cc5-960b-9295-912a-a7c37356a0c4@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/25/22 05:01, Amit Kapila wrote: > On Fri, Mar 25, 2022 at 3:29 AM Tomas Vondra > wrote: >> >> Pushed. >> > > Some of the comments given by me [1] don't seem to be addressed or > responded to. Let me try to say again for the ease of discussion: > D'oh! I got distracted by Petr's response to that message, and missed this part ... > * Don't we need some syncing mechanism between apply worker and > sequence sync worker so that apply worker skips the sequence changes > till the sync worker is finished, otherwise, there is a risk of one > overriding the values of the other? See how we take care of this for a > table in should_apply_changes_for_rel() and its callers. If we don't > do this for sequences for some reason then probably a comment > somewhere is required. > How would that happen? If we're effectively setting the sequence as a side effect of inserting the data, then why should we even replicate the sequence? We'll have the problem later too, no? > * Don't we need explicit privilege checking before applying sequence > data as we do in commit a2ab9c06ea15fbcb2bfde570986a06b37f52bcca for > tables? > So essentially something like TargetPrivilegesCheck in the worker? I think you're probably right we need something like that. > Few new comments: > ================= > 1. A simple test like the below crashes for me: > postgres=# create sequence s1; > CREATE SEQUENCE > postgres=# create sequence s2; > CREATE SEQUENCE > postgres=# create publication pub1 for sequence s1, s2; > server closed the connection unexpectedly > This probably means the server terminated abnormally > before or while processing the request. > The connection to the server was lost. Attempting reset: Failed. > Yeah, preprocess_pubobj_list seems to be a few bricks shy. I have a fix, will push shortly. > 2. In apply_handle_sequence() do we need AccessExclusiveLock for > non-transactional case? > Good catch. This lock was inherited from ResetSequence, but now that the transactional case works differently, we probably don't need it. > 3. In apply_handle_sequence(), I think for transactional case, we need > to skip the operation, if the skip lsn is set. See how we skip in > apply_handle_insert() and similar functions. > Right. Thanks for these reports! -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company