Add option to enable two_phase commits via pg_create_logical_replication_slot.
authorAmit Kapila <akapila@postgresql.org>
Wed, 3 Mar 2021 01:58:43 +0000 (07:28 +0530)
committerAmit Kapila <akapila@postgresql.org>
Wed, 3 Mar 2021 02:04:11 +0000 (07:34 +0530)
commit19890a064ebf53dedcefed0d8339ed3d449b06e6
tree76adf39f2d69ce5d6f8bda9efc48c34c0879e6bc
parentee28cacf619f4d9c23af5a80e1171a5adae97381
Add option to enable two_phase commits via pg_create_logical_replication_slot.

Commit 0aa8a01d04 extends the output plugin API to allow decoding of
prepared xacts and allowed the user to enable/disable the two-phase option
via pg_logical_slot_get_changes(). This can lead to a problem such that
the first time when it gets changes via pg_logical_slot_get_changes()
without two_phase option enabled it will not get the prepared even though
prepare is after consistent snapshot. Now next time during getting changes,
if the two_phase option is enabled it can skip prepare because by that
time start decoding point has been moved. So the user will only get commit
prepared.

Allow to enable/disable this option at the create slot time and default
will be false. It will break the existing slots which is fine in a major
release.

Author: Ajin Cherian
Reviewed-by: Amit Kapila and Vignesh C
Discussion: https://postgr.es/m/d0f60d60-133d-bf8d-bd70-47784d8fabf3@enterprisedb.com
20 files changed:
contrib/test_decoding/expected/twophase.out
contrib/test_decoding/expected/twophase_snapshot.out
contrib/test_decoding/expected/twophase_stream.out
contrib/test_decoding/specs/twophase_snapshot.spec
contrib/test_decoding/sql/twophase.sql
contrib/test_decoding/sql/twophase_stream.sql
contrib/test_decoding/test_decoding.c
doc/src/sgml/catalogs.sgml
doc/src/sgml/func.sgml
doc/src/sgml/logicaldecoding.sgml
src/backend/catalog/system_views.sql
src/backend/replication/logical/logical.c
src/backend/replication/slot.c
src/backend/replication/slotfuncs.c
src/backend/replication/walsender.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat
src/include/nodes/replnodes.h
src/include/replication/slot.h
src/test/regress/expected/rules.out