Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d27d493

Browse files
committed
Revert the assertion of no palloc's in critical section.
Per discussion, it still fires too often to be safe to enable in production. Keep it in master, so that we find the issues, but disable it in the stable branch.
1 parent 3130b85 commit d27d493

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

src/backend/utils/mmgr/mcxt.c

-24
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
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

5756
static 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,
533519
MemoryContext node;
534520
Size needed = size + strlen(name) + 1;
535521

536-
Assert(CritSectionCount == 0);
537-
538522
/* Get space for node and name */
539523
if (TopMemoryContext != NULL)
540524
{
@@ -591,7 +575,6 @@ MemoryContextAlloc(MemoryContext context, Size size)
591575
void *ret;
592576

593577
AssertArg(MemoryContextIsValid(context));
594-
AssertNotInCriticalSection(context);
595578

596579
if (!AllocSizeIsValid(size))
597580
elog(ERROR, "invalid memory alloc request size %zu", size);
@@ -617,7 +600,6 @@ MemoryContextAllocZero(MemoryContext context, Size size)
617600
void *ret;
618601

619602
AssertArg(MemoryContextIsValid(context));
620-
AssertNotInCriticalSection(context);
621603

622604
if (!AllocSizeIsValid(size))
623605
elog(ERROR, "invalid memory alloc request size %zu", size);
@@ -645,7 +627,6 @@ MemoryContextAllocZeroAligned(MemoryContext context, Size size)
645627
void *ret;
646628

647629
AssertArg(MemoryContextIsValid(context));
648-
AssertNotInCriticalSection(context);
649630

650631
if (!AllocSizeIsValid(size))
651632
elog(ERROR, "invalid memory alloc request size %zu", size);
@@ -667,7 +648,6 @@ palloc(Size size)
667648
void *ret;
668649

669650
AssertArg(MemoryContextIsValid(CurrentMemoryContext));
670-
AssertNotInCriticalSection(CurrentMemoryContext);
671651

672652
if (!AllocSizeIsValid(size))
673653
elog(ERROR, "invalid memory alloc request size %zu", size);
@@ -687,7 +667,6 @@ palloc0(Size size)
687667
void *ret;
688668

689669
AssertArg(MemoryContextIsValid(CurrentMemoryContext));
690-
AssertNotInCriticalSection(CurrentMemoryContext);
691670

692671
if (!AllocSizeIsValid(size))
693672
elog(ERROR, "invalid memory alloc request size %zu", size);
@@ -759,7 +738,6 @@ repalloc(void *pointer, Size size)
759738
((char *) pointer - STANDARDCHUNKHEADERSIZE))->context;
760739

761740
AssertArg(MemoryContextIsValid(context));
762-
AssertNotInCriticalSection(context);
763741

764742
/* isReset must be false already */
765743
Assert(!context->isReset);
@@ -782,7 +760,6 @@ MemoryContextAllocHuge(MemoryContext context, Size size)
782760
void *ret;
783761

784762
AssertArg(MemoryContextIsValid(context));
785-
AssertNotInCriticalSection(context);
786763

787764
if (!AllocHugeSizeIsValid(size))
788765
elog(ERROR, "invalid memory alloc request size %zu", size);
@@ -824,7 +801,6 @@ repalloc_huge(void *pointer, Size size)
824801
((char *) pointer - STANDARDCHUNKHEADERSIZE))->context;
825802

826803
AssertArg(MemoryContextIsValid(context));
827-
AssertNotInCriticalSection(context);
828804

829805
/* isReset must be false already */
830806
Assert(!context->isReset);

0 commit comments

Comments
 (0)