From 312ed69dfb2cde0d6a1dca5605fee8cade1f5bff Mon Sep 17 00:00:00 2001 From: cc_db_dev Date: Tue, 25 Apr 2023 16:13:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=BA=E9=99=B7=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E6=B1=A0=E5=BC=80=E5=90=AF=E6=97=B6=EF=BC=8C=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E4=BC=9A=E8=AF=9D=E5=86=85=E5=AD=98=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E8=B6=85=E5=87=BA=E4=B8=8A=E9=99=90=E6=97=B6?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/utils/mmgr/AsanMemoryAllocator.cpp | 3 ++- src/common/backend/utils/mmgr/aset.cpp | 2 +- src/common/backend/utils/mmgr/mcxt.cpp | 2 +- src/test/regress/expected/show_warnings.out | 12 ++++++++++++ src/test/regress/sql/show_warnings.sql | 7 +++++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/common/backend/utils/mmgr/AsanMemoryAllocator.cpp b/src/common/backend/utils/mmgr/AsanMemoryAllocator.cpp index 4084267b59..705a9f4ae7 100644 --- a/src/common/backend/utils/mmgr/AsanMemoryAllocator.cpp +++ b/src/common/backend/utils/mmgr/AsanMemoryAllocator.cpp @@ -269,7 +269,8 @@ MemoryContext AsanMemoryAllocator::AllocSetContextCreate(MemoryContext parent, c * Don't limit the memory allocation for ErrorContext. * And skip memory tracking memory allocation. */ - if ((strcmp(name, "ErrorContext") != 0) && (strcmp(name, "MemoryTrackMemoryContext") != 0)) { + if ((strcmp(name, "ErrorContext") != 0) && (strcmp(name, "MemoryTrackMemoryContext") != 0) + && (strcmp(name, "DolphinErrorData") != 0)) { value |= IS_PROTECT; } diff --git a/src/common/backend/utils/mmgr/aset.cpp b/src/common/backend/utils/mmgr/aset.cpp index f33d88b188..d121787f3b 100644 --- a/src/common/backend/utils/mmgr/aset.cpp +++ b/src/common/backend/utils/mmgr/aset.cpp @@ -495,7 +495,7 @@ MemoryContext GenericMemoryAllocator::AllocSetContextCreate(MemoryContext parent * Don't limit the memory allocation for ErrorContext. And skip memory tracking memory allocation. */ if ((0 != strcmp(name, "ErrorContext")) && (0 != strcmp(name, "MemoryTrackMemoryContext")) && - (strcmp(name, "Track MemoryInfo hash") != 0)) + (strcmp(name, "Track MemoryInfo hash") != 0) && (0 != strcmp(name, "DolphinErrorData"))) value |= IS_PROTECT; /* only track the unshared context after t_thrd.mem_cxt.mem_track_mem_cxt is created */ diff --git a/src/common/backend/utils/mmgr/mcxt.cpp b/src/common/backend/utils/mmgr/mcxt.cpp index b2e8a4985f..4e4adb67f1 100644 --- a/src/common/backend/utils/mmgr/mcxt.cpp +++ b/src/common/backend/utils/mmgr/mcxt.cpp @@ -937,7 +937,7 @@ MemoryContext MemoryContextCreate( } /* check if the memory context is out of control */ -#define MEMORY_CONTEXT_CONTROL_LEVEL 3 // ExecutorState +#define MEMORY_CONTEXT_CONTROL_LEVEL (ENABLE_THREAD_POOL ? 5: 3) // ExecutorState void MemoryContextCheckMaxSize(MemoryContext context, Size size, const char* file, int line) { #ifndef ENABLE_MEMORY_CHECK diff --git a/src/test/regress/expected/show_warnings.out b/src/test/regress/expected/show_warnings.out index a118d40eab..6ac3a98607 100644 --- a/src/test/regress/expected/show_warnings.out +++ b/src/test/regress/expected/show_warnings.out @@ -153,5 +153,17 @@ show warnings limit 2, 4; Warning | 64 | you don't own a lock of type ShareLock (2 rows) +show enable_thread_pool; + enable_thread_pool +-------------------- + on +(1 row) + +set query_mem='32MB'; +set query_max_mem='32MB'; +create table aaa(a int,b date,partial cluster key(b)) with (orientation = column); +insert into aaa(a ) select generate_series(1,10000000); +--?ERROR: Session used memory .* Kbytes is beyond the limitation 32768 Kbytes. +--?DETAIL: Session estimated memory is.* \c postgres drop database if exists db_show_warnings; diff --git a/src/test/regress/sql/show_warnings.sql b/src/test/regress/sql/show_warnings.sql index 7637c60d21..ce35dfdb6d 100644 --- a/src/test/regress/sql/show_warnings.sql +++ b/src/test/regress/sql/show_warnings.sql @@ -45,5 +45,12 @@ SELECT pg_advisory_unlock(1), pg_advisory_unlock_shared(2), pg_advisory_unlock(1 show warnings; show warnings limit 2, 4; +show enable_thread_pool; +set query_mem='32MB'; +set query_max_mem='32MB'; +create table aaa(a int,b date,partial cluster key(b)) with (orientation = column); +insert into aaa(a ) select generate_series(1,10000000); + + \c postgres drop database if exists db_show_warnings; -- Gitee