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-04-02T11:58:43Z
Lists: pgsql-hackers
On 4/2/22 12:43, Amit Kapila wrote: > On Sat, Apr 2, 2022 at 5:47 AM Tomas Vondra > <tomas.vondra@enterprisedb.com> wrote: >> >> On 4/1/22 17:02, Tomas Vondra wrote: >> >> The only option I see is reworking the decoding so that it does not need >> the snapshot at all. We'll need to stash the changes just like any other >> change, apply them at end of transaction, and the main difference >> between transactional and non-transactional case would be what happens >> at abort. Transactional changes would be discarded, non-transactional >> would be applied anyway. >> > > I think in the above I am not following how we can make it work > without considering *snapshot at all* because based on that we would > have done the initial sync (copy_sequence) and if we don't follow that > later it can lead to inconsistency. I might be missing something here. > Well, what I meant to say is that we can't consider the snapshot at this phase of decoding. We'd still consider it later, at commit/abort time, of course. I.e. it'd be fairly similar to what heap_decode/DecodeInsert does, for example. AFAIK this does not build the snapshot anywhere. >> The challenge is this reorders the sequence changes, so we'll need to >> reconcile them somehow. One option would be to simply (1) apply the >> change with the highest LSN in the transaction, and then walk all other >> in-progress transactions and changes for that sequence with a lower LSN. >> Not sure how complex/expensive that would be, though. Another problem is >> not all increments are WAL-logged, of course, not sure about that. >> >> Another option might be revisiting the approach proposed by Hannu in >> September [1], i.e. tracking sequences touched in a transaction, and >> then replicating the current state at that particular moment. >> > > I'll think about that approach as well. > Thanks! -- 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