Re: logical decoding and replication of sequences, take 2
Tomas Vondra <tomas.vondra@enterprisedb.com>
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>,
"Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>,
Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Masahiko Sawada <sawada.mshk@gmail.com>,
Peter Eisentraut <peter.eisentraut@enterprisedb.com>,
Dilip Kumar <dilipbalaut@gmail.com>
Date: 2023-11-29T13:28:47Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Migrate logical slots to the new node during an upgrade.
- 29d0a77fa660 17.0 cited
-
Make test_decoding ddl.out shorter
- d6677b93c79b 17.0 landed
- c5c5832600e9 14.9 landed
- b1dc946eee3d 16.0 landed
- 3bb8b9342f8a 15.4 landed
-
Fix snapshot handling in logicalmsg_decode
- 949ac32e1267 15.3 landed
- 8b9cbd42b61f 14.8 landed
- 4df581fa0f4b 13.11 landed
- 497f863f0598 12.15 landed
- 8de91ebf2ac1 11.20 landed
- 7fe1aa991b62 16.0 landed
-
doc: Adjust a few more references to "postmaster"
- 17e72ec45d31 16.0 cited
-
Revert "Logical decoding of sequences"
- 2c7ea57e56ca 15.0 cited
Attachments
- v20231128-0001-Logical-decoding-of-sequences.patch (text/x-patch) patch v20231128-0001
- v20231128-0002-tweak-ReorderBufferSequenceIsTransactional.patch (text/x-patch) patch v20231128-0002
- v20231128-0003-Add-decoding-of-sequences-to-test_decoding.patch (text/x-patch) patch v20231128-0003
- v20231128-0004-Add-decoding-of-sequences-to-built-in-repl.patch (text/x-patch) patch v20231128-0004
Hi! Considering my findings about issues with the rd_newRelfilelocatorSubid field and how it makes that approach impossible, I decided to rip out those patches, and go back to the approach where reorderbuffer tracks new relfilenodes. This means the open questions I listed two days ago disappear, because all of that was about the alternative approach. I've also added a couple more tests into 034_sequences.pl, testing the basic cases with substransactions that rollback (or not), etc. The attached patch also addresses the review comments by Peter Smith. The one remaining open question is ReorderBufferSequenceIsTransactional and whether it can do better than searching through all top-level transactions. The idea of 0002 was to only search the current top-level xact, but Amit pointed out we can't rely on seeing the assignment until we know we're in a consistent snapshot. I'm yet to try doing some tests to measure how expensive this lookup can be in practice. But let's assume it's measurable and significant enough to matter. I wonder if we could salvage this optimization somehow. I'm thinking about three options: 1) Could ReorderBufferSequenceIsTransactional check the snapshot is already consistent etc. and use the optimized variant (looking only at the same top-level xact) in that case? And if not, fallback to the search of all top-level xacts. In practice, the full search would be used only for a short initial period. 2) We could also make ReorderBufferSequenceIsTransactional to always check the same top-level transaction first and then fallback, no matter whether the snapshot is consistent or not. The problem is this doesn't really optimize the common case where there are no new relfilenodes, so we won't find a match in the top-level xact, and will always search everything anyway. 3) Alternatively, we could maintain a global hash table, instead of in the top-level transaction. So there'd always be two copies, one in the xact itself and then in the global hash. Now there's either one (in current top-level xact), or two (subxact + top-level xact). I kinda like (3), because it just works and doesn't require the snapshot being consistent etc. Opinions? -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company