diff options
Diffstat (limited to 'src/backend/utils/mmgr/portalmem.c')
-rw-r--r-- | src/backend/utils/mmgr/portalmem.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index 88b7908310f..2553997f47b 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -440,8 +440,8 @@ MarkPortalDone(Portal portal) * well do that now, since the portal can't be executed any more. * * In some cases involving execution of a ROLLBACK command in an already - * aborted transaction, this prevents an assertion failure caused by - * reaching AtCleanup_Portals with the cleanup hook still unexecuted. + * aborted transaction, this is necessary, or we'd reach AtCleanup_Portals + * with the cleanup hook still unexecuted. */ if (PointerIsValid(portal->cleanup)) { @@ -468,8 +468,8 @@ MarkPortalFailed(Portal portal) * well do that now, since the portal can't be executed any more. * * In some cases involving cleanup of an already aborted transaction, this - * prevents an assertion failure caused by reaching AtCleanup_Portals with - * the cleanup hook still unexecuted. + * is necessary, or we'd reach AtCleanup_Portals with the cleanup hook + * still unexecuted. */ if (PointerIsValid(portal->cleanup)) { @@ -846,8 +846,15 @@ AtCleanup_Portals(void) if (portal->portalPinned) portal->portalPinned = false; - /* We had better not be calling any user-defined code here */ - Assert(portal->cleanup == NULL); + /* + * We had better not call any user-defined code during cleanup, so if + * the cleanup hook hasn't been run yet, too bad; we'll just skip it. + */ + if (PointerIsValid(portal->cleanup)) + { + elog(WARNING, "skipping cleanup for portal \"%s\"", portal->name); + portal->cleanup = NULL; + } /* Zap it. */ PortalDrop(portal, false); @@ -1025,8 +1032,15 @@ AtSubCleanup_Portals(SubTransactionId mySubid) if (portal->portalPinned) portal->portalPinned = false; - /* We had better not be calling any user-defined code here */ - Assert(portal->cleanup == NULL); + /* + * We had better not call any user-defined code during cleanup, so if + * the cleanup hook hasn't been run yet, too bad; we'll just skip it. + */ + if (PointerIsValid(portal->cleanup)) + { + elog(WARNING, "skipping cleanup for portal \"%s\"", portal->name); + portal->cleanup = NULL; + } /* Zap it. */ PortalDrop(portal, false); |