Avoid repeated decoding of prepared transactions after a restart.
authorAmit Kapila <akapila@postgresql.org>
Mon, 1 Mar 2021 03:41:18 +0000 (09:11 +0530)
committerAmit Kapila <akapila@postgresql.org>
Mon, 1 Mar 2021 03:41:18 +0000 (09:11 +0530)
commit8bdb1332eb51837c15a10a972c179b84f654279e
treebadfa4657b5a985fb4d13564e9fc810f0d425f88
parent6230912f23904aa6cb2a1f948ca9b08235b4f54a
Avoid repeated decoding of prepared transactions after a restart.

In commit a271a1b50e, we allowed decoding at prepare time and the prepare
was decoded again if there is a restart after decoding it. It was done
that way because we can't distinguish between the cases where we have not
decoded the prepare because it was prior to consistent snapshot or we have
decoded it earlier but restarted. To distinguish between these two cases,
we have introduced an initial_consistent_point at the slot level which is
an LSN at which we found a consistent point at the time of slot creation.
This is also the point where we have exported a snapshot for the initial
copy. So, prepare transaction prior to this point are sent along with
commit prepared.

This commit bumps SNAPBUILD_VERSION because of change in SnapBuild. It
will break existing slots which is fine in a major release.

Author: Ajin Cherian, based on idea by Andres Freund
Reviewed-by: Amit Kapila and Vignesh C
Discussion: https://postgr.es/m/d0f60d60-133d-bf8d-bd70-47784d8fabf3@enterprisedb.com
contrib/test_decoding/expected/twophase.out
contrib/test_decoding/expected/twophase_stream.out
doc/src/sgml/logicaldecoding.sgml
src/backend/replication/logical/decode.c
src/backend/replication/logical/logical.c
src/backend/replication/logical/reorderbuffer.c
src/backend/replication/logical/snapbuild.c
src/include/replication/reorderbuffer.h
src/include/replication/slot.h
src/include/replication/snapbuild.h