@@ -1378,7 +1378,7 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
1378
1378
{
1379
1379
/* The cache only lives as long as the current transaction */
1380
1380
debug_elog2 (DEBUG2 ,"CachePut: initializing memory context" );
1381
- MXactContext = AllocSetContextCreate (TopTransactionContext ,
1381
+ MXactContext = AllocSetContextCreate (TopMemoryContext ,
1382
1382
"MultiXact cache context" ,
1383
1383
ALLOCSET_SMALL_SIZES );
1384
1384
}
@@ -1484,7 +1484,11 @@ AtEOXact_MultiXact(void)
1484
1484
* Discard the local MultiXactId cache. Since MXactContext was created as
1485
1485
* a child of TopTransactionContext, we needn't delete it explicitly.
1486
1486
*/
1487
- MXactContext = NULL ;
1487
+ if (MXactContext )
1488
+ {
1489
+ MemoryContextDelete (MXactContext );
1490
+ MXactContext = NULL ;
1491
+ }
1488
1492
dlist_init (& MXactCache );
1489
1493
MXactCacheMembers = 0 ;
1490
1494
}
@@ -1551,7 +1555,11 @@ PostPrepare_MultiXact(TransactionId xid)
1551
1555
/*
1552
1556
* Discard the local MultiXactId cache like in AtEOX_MultiXact
1553
1557
*/
1554
- MXactContext = NULL ;
1558
+ if (MXactContext )
1559
+ {
1560
+ MemoryContextDelete (MXactContext );
1561
+ MXactContext = NULL ;
1562
+ }
1555
1563
dlist_init (& MXactCache );
1556
1564
MXactCacheMembers = 0 ;
1557
1565
}