From 2c332a233290f7fae6c619cd78254cbe9c4afe99 Mon Sep 17 00:00:00 2001 From: Yura Sokolov Date: Fri, 11 Jun 2021 11:40:41 +0300 Subject: [PATCH] Adapt mmts for commit ef94805096 Due to ef94805096 'Restore the portal-level snapshot after procedure COMMIT/ROLLBACK.' there should be ActiveSnapshot set. Otherwise EnsurePortalSnapshotExists will assert on ActivePortal->portalSnapshot == NULL since current portal has snapshot in outer transaction. Tags: multimaster --- src/ddl.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ddl.c b/src/ddl.c index 0e2cae1e54..0bd82284c0 100644 --- a/src/ddl.c +++ b/src/ddl.c @@ -1401,9 +1401,18 @@ MtmApplyDDLMessage(const char *messageBody, bool transactional) DDLApplyInProgress = transactional ? MTM_DDL_IN_PROGRESS_TX : MTM_DDL_IN_PROGRESS_NONTX; + + /* + * Due to ef94805096 'Restore the portal-level snapshot after procedure COMMIT/ROLLBACK.' + * there should be ActiveSnapshot set. Otherwise EnsurePortalSnapshotExists + * will assert on ActivePortal->portalSnapshot == NULL since current + * portal has snapshot in outer transaction. + */ + PushActiveSnapshot(GetTransactionSnapshot()); SPI_connect(); rc = SPI_execute(messageBody, false, 0); SPI_finish(); + PopActiveSnapshot(); if (rc < 0) elog(ERROR, "Failed to execute utility statement %s", messageBody);