24
24
25
25
#include "postgres.h"
26
26
27
- #include "miscadmin.h"
28
27
#include "utils/memdebug.h"
29
28
#include "utils/memutils.h"
30
29
@@ -56,19 +55,6 @@ MemoryContext PortalContext = NULL;
56
55
57
56
static void MemoryContextStatsInternal (MemoryContext context , int level );
58
57
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())
72
58
73
59
/*****************************************************************************
74
60
* EXPORTED ROUTINES *
@@ -533,8 +519,6 @@ MemoryContextCreate(NodeTag tag, Size size,
533
519
MemoryContext node ;
534
520
Size needed = size + strlen (name ) + 1 ;
535
521
536
- Assert (CritSectionCount == 0 );
537
-
538
522
/* Get space for node and name */
539
523
if (TopMemoryContext != NULL )
540
524
{
@@ -591,7 +575,6 @@ MemoryContextAlloc(MemoryContext context, Size size)
591
575
void * ret ;
592
576
593
577
AssertArg (MemoryContextIsValid (context ));
594
- AssertNotInCriticalSection (context );
595
578
596
579
if (!AllocSizeIsValid (size ))
597
580
elog (ERROR , "invalid memory alloc request size %zu" , size );
@@ -617,7 +600,6 @@ MemoryContextAllocZero(MemoryContext context, Size size)
617
600
void * ret ;
618
601
619
602
AssertArg (MemoryContextIsValid (context ));
620
- AssertNotInCriticalSection (context );
621
603
622
604
if (!AllocSizeIsValid (size ))
623
605
elog (ERROR , "invalid memory alloc request size %zu" , size );
@@ -645,7 +627,6 @@ MemoryContextAllocZeroAligned(MemoryContext context, Size size)
645
627
void * ret ;
646
628
647
629
AssertArg (MemoryContextIsValid (context ));
648
- AssertNotInCriticalSection (context );
649
630
650
631
if (!AllocSizeIsValid (size ))
651
632
elog (ERROR , "invalid memory alloc request size %zu" , size );
@@ -667,7 +648,6 @@ palloc(Size size)
667
648
void * ret ;
668
649
669
650
AssertArg (MemoryContextIsValid (CurrentMemoryContext ));
670
- AssertNotInCriticalSection (CurrentMemoryContext );
671
651
672
652
if (!AllocSizeIsValid (size ))
673
653
elog (ERROR , "invalid memory alloc request size %zu" , size );
@@ -687,7 +667,6 @@ palloc0(Size size)
687
667
void * ret ;
688
668
689
669
AssertArg (MemoryContextIsValid (CurrentMemoryContext ));
690
- AssertNotInCriticalSection (CurrentMemoryContext );
691
670
692
671
if (!AllocSizeIsValid (size ))
693
672
elog (ERROR , "invalid memory alloc request size %zu" , size );
@@ -759,7 +738,6 @@ repalloc(void *pointer, Size size)
759
738
((char * ) pointer - STANDARDCHUNKHEADERSIZE ))-> context ;
760
739
761
740
AssertArg (MemoryContextIsValid (context ));
762
- AssertNotInCriticalSection (context );
763
741
764
742
/* isReset must be false already */
765
743
Assert (!context -> isReset );
@@ -782,7 +760,6 @@ MemoryContextAllocHuge(MemoryContext context, Size size)
782
760
void * ret ;
783
761
784
762
AssertArg (MemoryContextIsValid (context ));
785
- AssertNotInCriticalSection (context );
786
763
787
764
if (!AllocHugeSizeIsValid (size ))
788
765
elog (ERROR , "invalid memory alloc request size %zu" , size );
@@ -824,7 +801,6 @@ repalloc_huge(void *pointer, Size size)
824
801
((char * ) pointer - STANDARDCHUNKHEADERSIZE ))-> context ;
825
802
826
803
AssertArg (MemoryContextIsValid (context ));
827
- AssertNotInCriticalSection (context );
828
804
829
805
/* isReset must be false already */
830
806
Assert (!context -> isReset );
0 commit comments