#include "replication/logical.h"
#include "replication/logicallauncher.h"
#include "replication/origin.h"
+#include "replication/snapbuild.h"
#include "replication/syncrep.h"
#include "replication/walsender.h"
#include "storage/condition_variable.h"
/* Reset logical streaming state. */
ResetLogicalStreamingState();
+ /* Reset snapshot export state. */
+ SnapBuildResetExportedSnapshotState();
+
/* If in parallel mode, clean up workers and exit parallel mode. */
if (IsInParallelMode())
{
/* Reset logical streaming state. */
ResetLogicalStreamingState();
+ /*
+ * No need for SnapBuildResetExportedSnapshotState() here, snapshot
+ * exports are not supported in subtransactions.
+ */
+
/* Exit from parallel mode, if necessary. */
if (IsInParallelMode())
{
void
SnapBuildClearExportedSnapshot(void)
{
+ ResourceOwner tmpResOwner;
+
/* nothing exported, that is the usual case */
if (!ExportInProgress)
return;
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;
}
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,