Fix uninitialized access to InitialRunningXacts during decoding after ERROR.
authorAmit Kapila <akapila@postgresql.org>
Tue, 12 Sep 2023 04:42:51 +0000 (10:12 +0530)
committerAmit Kapila <akapila@postgresql.org>
Tue, 12 Sep 2023 04:42:51 +0000 (10:12 +0530)
commitf7d25117ba87af67e3d6c50a30d96883c802bc88
treef80e109118143347e6aa87dfc9753ae0a067f407
parent2f13e8d9ec285e57775369a44fc4c47f7488f087
Fix uninitialized access to InitialRunningXacts during decoding after ERROR.

The transactions and subtransactions array that was allocated under
snapshot builder memory context and recorded during decoding was not
cleared in case of errors. This can result in an assertion failure if we
attempt to retry logical decoding within the same session. To address this
issue, we register a callback function under the snapshot builder memory
context to clear the recorded transactions and subtransactions array along
with the context.

This problem doesn't exist in PG16 and HEAD as instead of using
InitialRunningXacts, we added the list of transaction IDs and
sub-transaction IDs, that have modified catalogs and are running during
snapshot serialization, to the serialized snapshot (see commit 7f13ac8123).

Author: Hou Zhijie
Reviewed-by: Amit Kapila
Backpatch-through: 11
Discussion: http://postgr.es/m/18055-ab3beed9f4b7b7d6@postgresql.org
src/backend/replication/logical/snapbuild.c