Re: logical decoding and replication of sequences
Tomas Vondra <tomas.vondra@enterprisedb.com>
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Petr Jelinek <petr.jelinek@enterprisedb.com>,
Peter Eisentraut <peter.eisentraut@enterprisedb.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-03-25T10:26:39Z
Lists: pgsql-hackers
On 3/25/22 05:01, Amit Kapila wrote: > On Fri, Mar 25, 2022 at 3:29 AM Tomas Vondra > <tomas.vondra@enterprisedb.com> 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
Commits
-
Fix cache invalidation bug in recovery_prefetch.
- d0d934490020 15.0 landed
- 932b01630095 16.0 landed
-
Revert "Logical decoding of sequences"
- 2c7ea57e56ca 15.0 landed
-
Minor improvements in sequence decoding code and docs
- 05843b1aa49d 15.0 landed
-
Handle sequences in preprocess_pubobj_list
- 002c9dd97a0c 15.0 landed
-
Update tab-completion for CREATE PUBLICATION with sequences
- 2d2232933b02 15.0 landed
-
Add decoding of sequences to built-in replication
- 75b1521dae1f 15.0 landed
-
Stabilize test_decoding touching with sequences
- a180c2b34de0 15.0 landed
-
Call ReorderBufferProcessXid from sequence_decode
- d5ed9da41d96 15.0 landed
-
Add decoding of sequences to test_decoding
- 80901b32913f 15.0 landed
-
Replace Test::More plans with done_testing
- 549ec201d613 15.0 cited
-
Logical decoding of sequences
- 0da92dc530c9 15.0 landed
-
Respect permissions within logical replication.
- a2ab9c06ea15 15.0 cited