2424
2525#include "postgres.h"
2626
27- #include "miscadmin.h"
2827#include "utils/memdebug.h"
2928#include "utils/memutils.h"
3029
@@ -56,19 +55,6 @@ MemoryContext PortalContext = NULL;
5655
5756static void MemoryContextStatsInternal (MemoryContext context ,int level );
5857
59- /*
60- * You should not do memory allocations within a critical section, because
61- * an out-of-memory error will be escalated to a PANIC. To enforce that
62- * rule, the allocation functions Assert that.
63- *
64- * There are a two exceptions: 1) error recovery uses ErrorContext, which
65- * has some memory set aside so that you don't run out. And 2) checkpointer
66- * currently just hopes for the best, which is wrong and ought to be fixed,
67- * but it's a known issue so let's not complain about in the meanwhile.
68- */
69- #define AssertNotInCriticalSection (context ) \
70- Assert(CritSectionCount == 0 || (context) == ErrorContext || \
71- AmCheckpointerProcess())
7258
7359/*****************************************************************************
7460 * EXPORTED ROUTINES *
@@ -533,8 +519,6 @@ MemoryContextCreate(NodeTag tag, Size size,
533519MemoryContext node ;
534520Size needed = size + strlen (name )+ 1 ;
535521
536- Assert (CritSectionCount == 0 );
537-
538522/* Get space for node and name */
539523if (TopMemoryContext != NULL )
540524{
@@ -591,7 +575,6 @@ MemoryContextAlloc(MemoryContext context, Size size)
591575void * ret ;
592576
593577AssertArg (MemoryContextIsValid (context ));
594- AssertNotInCriticalSection (context );
595578
596579if (!AllocSizeIsValid (size ))
597580elog (ERROR ,"invalid memory alloc request size %zu" ,size );
@@ -617,7 +600,6 @@ MemoryContextAllocZero(MemoryContext context, Size size)
617600void * ret ;
618601
619602AssertArg (MemoryContextIsValid (context ));
620- AssertNotInCriticalSection (context );
621603
622604if (!AllocSizeIsValid (size ))
623605elog (ERROR ,"invalid memory alloc request size %zu" ,size );
@@ -645,7 +627,6 @@ MemoryContextAllocZeroAligned(MemoryContext context, Size size)
645627void * ret ;
646628
647629AssertArg (MemoryContextIsValid (context ));
648- AssertNotInCriticalSection (context );
649630
650631if (!AllocSizeIsValid (size ))
651632elog (ERROR ,"invalid memory alloc request size %zu" ,size );
@@ -667,7 +648,6 @@ palloc(Size size)
667648void * ret ;
668649
669650AssertArg (MemoryContextIsValid (CurrentMemoryContext ));
670- AssertNotInCriticalSection (CurrentMemoryContext );
671651
672652if (!AllocSizeIsValid (size ))
673653elog (ERROR ,"invalid memory alloc request size %zu" ,size );
@@ -687,7 +667,6 @@ palloc0(Size size)
687667void * ret ;
688668
689669AssertArg (MemoryContextIsValid (CurrentMemoryContext ));
690- AssertNotInCriticalSection (CurrentMemoryContext );
691670
692671if (!AllocSizeIsValid (size ))
693672elog (ERROR ,"invalid memory alloc request size %zu" ,size );
@@ -759,7 +738,6 @@ repalloc(void *pointer, Size size)
759738 ((char * )pointer - STANDARDCHUNKHEADERSIZE ))-> context ;
760739
761740AssertArg (MemoryContextIsValid (context ));
762- AssertNotInCriticalSection (context );
763741
764742/* isReset must be false already */
765743Assert (!context -> isReset );
@@ -782,7 +760,6 @@ MemoryContextAllocHuge(MemoryContext context, Size size)
782760void * ret ;
783761
784762AssertArg (MemoryContextIsValid (context ));
785- AssertNotInCriticalSection (context );
786763
787764if (!AllocHugeSizeIsValid (size ))
788765elog (ERROR ,"invalid memory alloc request size %zu" ,size );
@@ -824,7 +801,6 @@ repalloc_huge(void *pointer, Size size)
824801 ((char * )pointer - STANDARDCHUNKHEADERSIZE ))-> context ;
825802
826803AssertArg (MemoryContextIsValid (context ));
827- AssertNotInCriticalSection (context );
828804
829805/* isReset must be false already */
830806Assert (!context -> isReset );