aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/logical/snapbuild.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/replication/logical/snapbuild.c')
-rw-r--r--src/backend/replication/logical/snapbuild.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c
index 04f3355f602..6df602485b3 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -673,6 +673,8 @@ SnapBuildGetOrBuildSnapshot(SnapBuild *builder, TransactionId xid)
void
SnapBuildClearExportedSnapshot(void)
{
+ ResourceOwner tmpResOwner;
+
/* nothing exported, that is the usual case */
if (!ExportInProgress)
return;
@@ -680,10 +682,24 @@ SnapBuildClearExportedSnapshot(void)
if (!IsTransactionState())
elog(ERROR, "clearing exported snapshot in wrong transaction state");
- /* make sure nothing could have ever happened */
+ /*
+ * AbortCurrentTransaction() takes care of resetting the snapshot state,
+ * so remember SavedResourceOwnerDuringExport.
+ */
+ tmpResOwner = SavedResourceOwnerDuringExport;
+
+ /* make sure nothing could have ever happened */
AbortCurrentTransaction();
- CurrentResourceOwner = SavedResourceOwnerDuringExport;
+ CurrentResourceOwner = tmpResOwner;
+}
+
+/*
+ * Clear snapshot export state during transaction abort.
+ */
+void
+SnapBuildResetExportedSnapshotState(void)
+{
SavedResourceOwnerDuringExport = NULL;
ExportInProgress = false;
}