postgresql/contrib/test_decoding/expected
Amit Kapila e721123b7a Fix catalog lookup with the wrong snapshot during logical decoding.
Previously, we relied on HEAP2_NEW_CID records and XACT_INVALIDATION
records to know if the transaction has modified the catalog, and that
information is not serialized to snapshot. Therefore, after the restart,
if the logical decoding decodes only the commit record of the transaction
that has actually modified a catalog, we will miss adding its XID to the
snapshot. Thus, we will end up looking at catalogs with the wrong
snapshot.

To fix this problem, this changes the snapshot builder so that it
remembers the last-running-xacts list of the decoded RUNNING_XACTS record
after restoring the previously serialized snapshot. Then, we mark the
transaction as containing catalog changes if it's in the list of initial
running transactions and its commit record has XACT_XINFO_HAS_INVALS. To
avoid ABI breakage, we store the array of the initial running transactions
in the static variables InitialRunningXacts and NInitialRunningXacts,
instead of storing those in SnapBuild or ReorderBuffer.

This approach has a false positive; we could end up adding the transaction
that didn't change catalog to the snapshot since we cannot distinguish
whether the transaction has catalog changes only by checking the COMMIT
record. It doesn't have the information on which (sub) transaction has
catalog changes, and XACT_XINFO_HAS_INVALS doesn't necessarily indicate
that the transaction has catalog change. But that won't be a problem since
we use snapshot built during decoding only to read system catalogs.

On the master branch, we took a more future-proof approach by writing
catalog modifying transactions to the serialized snapshot which avoids the
above false positive. But we cannot backpatch it because of a change in
the SnapBuild.

Reported-by: Mike Oh
Author: Masahiko Sawada
Reviewed-by: Amit Kapila, Shi yu, Takamichi Osumi, Kyotaro Horiguchi, Bertrand Drouvot, Ahsan Hadi
Backpatch-through: 10
Discussion: https://postgr.es/m/81D0D8B0-E7C4-4999-B616-1E5004DBDCD2%40amazon.com
2022-08-11 08:55:31 +05:30
..
binary.out
catalog_change_snapshot.out Fix catalog lookup with the wrong snapshot during logical decoding. 2022-08-11 08:55:31 +05:30
concurrent_ddl_dml.out Improve display of query results in isolation tests. 2021-06-23 11:12:31 -04:00
ddl.out Relax overly strict assertion 2019-02-12 18:42:37 -03:00
decoding_in_xact.out
decoding_into_rel.out Fix crash when logical decoding is invoked from a PL function. 2017-10-06 19:18:58 -04:00
delayed_startup.out Improve display of query results in isolation tests. 2021-06-23 11:12:31 -04:00
messages.out Add required database and origin filtering for logical messages. 2016-04-13 17:38:54 -07:00
mxact.out Improve display of query results in isolation tests. 2021-06-23 11:12:31 -04:00
oldest_xmin.out Improve display of query results in isolation tests. 2021-06-23 11:12:31 -04:00
ondisk_startup.out Improve display of query results in isolation tests. 2021-06-23 11:12:31 -04:00
permissions.out Replace AclObjectKind with ObjectType 2018-01-19 14:01:15 -05:00
prepared.out
replorigin.out Remove assertion for replication origins in PREPARE TRANSACTION 2021-12-14 10:58:37 +09:00
rewrite.out Fix potential assertion failure when reindexing a pg_class index. 2019-04-29 19:42:09 -07:00
slot.out Fix logical replication slot initialization 2018-08-01 17:39:07 -04:00
snapshot_transfer.out Improve display of query results in isolation tests. 2021-06-23 11:12:31 -04:00
spill.out Make contrib/test_decoding regression tests safe for CZ locale. 2016-11-21 20:39:28 -05:00
subxact_without_top.out Improve display of query results in isolation tests. 2021-06-23 11:12:31 -04:00
time.out
toast.out WAL log unchanged toasted replica identity key attributes. 2022-02-14 08:37:23 +05:30
truncate.out Logical decoding of TRUNCATE 2018-04-07 11:34:10 -04:00
xact.out Don't propagate a null subtransaction snapshot up to parent transaction. 2016-08-07 13:15:55 -04:00