summaryrefslogtreecommitdiff
path: root/src/include/replication
diff options
context:
space:
mode:
authorMichael Paquier2021-10-18 02:55:42 +0000
committerMichael Paquier2021-10-18 02:55:42 +0000
commit409f9ca4471331be0f77b665ff3a1836a41de5b3 (patch)
treec27ce0d8603a0e9e8a08ab61c1ceca8dd1c00737 /src/include/replication
parent384f1abdb9b0f669279fcd57ba2173eb31724740 (diff)
Reset properly snapshot export state during transaction abort
During a replication slot creation, an ERROR generated in the same transaction as the one creating a to-be-exported snapshot would have left the backend in an inconsistent state, as the associated static export snapshot state was not being reset on transaction abort, but only on the follow-up command received by the WAL sender that created this snapshot on replication slot creation. This would trigger inconsistency failures if this session tried to export again a snapshot, like during the creation of a replication slot. Note that a snapshot export cannot happen in a transaction block, so there is no need to worry resetting this state for subtransaction aborts. Also, this inconsistent state would very unlikely show up to users. For example, one case where this could happen is an out-of-memory error when building the initial snapshot to-be-exported. Dilip found this problem while poking at a different patch, that caused an error in this code path for reasons unrelated to HEAD. Author: Dilip Kumar Reviewed-by: Michael Paquier, Zhihong Yu Discussion: https://postgr.es/m/CAFiTN-s0zA1Kj0ozGHwkYkHwa5U0zUE94RSc_g81WrpcETB5=w@mail.gmail.com Backpatch-through: 9.6
Diffstat (limited to 'src/include/replication')
-rw-r--r--src/include/replication/snapbuild.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/replication/snapbuild.h b/src/include/replication/snapbuild.h
index de7212464af..82aa86125b9 100644
--- a/src/include/replication/snapbuild.h
+++ b/src/include/replication/snapbuild.h
@@ -70,6 +70,7 @@ extern void SnapBuildSnapDecRefcount(Snapshot snap);
extern Snapshot SnapBuildInitialSnapshot(SnapBuild *builder);
extern const char *SnapBuildExportSnapshot(SnapBuild *snapstate);
extern void SnapBuildClearExportedSnapshot(void);
+extern void SnapBuildResetExportedSnapshotState(void);
extern SnapBuildState SnapBuildCurrentState(SnapBuild *snapstate);
extern Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder,