From a6be5c7abb4111dea496b3b6a3f065ee019581dc Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 1 Dec 2025 10:20:24 +0500 Subject: [PATCH 01/41] Restore old logic for limiting sizes of table_size and quota_info_map --- src/diskquota.c | 15 +++++++++++++++ src/diskquota.h | 2 ++ src/diskquota_utility.c | 27 +++++++++++++++++++++++++++ src/quotamodel.c | 26 ++++++++++++++++++-------- 4 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/diskquota.c b/src/diskquota.c index aa706f40..cb7f5ab3 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -91,6 +91,12 @@ static DiskQuotaWorkerEntry *volatile MyWorkerInfo = NULL; // how many database diskquota are monitoring on static int num_db = 0; +/* how many TableSizeEntry are maintained in all the table_size_map in shared memory*/ +pg_atomic_uint32 *diskquota_table_size_entry_num; + +/* how many QuotaInfoEntry are maintained in all the quota_info_map in shared memory*/ +pg_atomic_uint32 *diskquota_quota_info_entry_num; + static DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem; #define MIN_SLEEPTIME 100 /* milliseconds */ @@ -1772,6 +1778,15 @@ init_launcher_shmem() DiskquotaLauncherShmem->dbArray[i].workerId = INVALID_WORKER_ID; } } + /* init TableSizeEntry counter */ + diskquota_table_size_entry_num = + ShmemInitStruct("diskquota TableSizeEntry counter", sizeof(pg_atomic_uint32), &found); + if (!found) pg_atomic_init_u32(diskquota_table_size_entry_num, 0); + + /* init QuotaInfoEntry counter */ + diskquota_quota_info_entry_num = + ShmemInitStruct("diskquota QuotaInfoEntry counter", sizeof(pg_atomic_uint32), &found); + if (!found) pg_atomic_init_u32(diskquota_quota_info_entry_num, 0); } /* diff --git a/src/diskquota.h b/src/diskquota.h index c46adb21..921a5cdc 100644 --- a/src/diskquota.h +++ b/src/diskquota.h @@ -319,6 +319,8 @@ extern HTAB *DiskquotaShmemInitHash(const char *name, long init_size, long max_s extern void refresh_monitored_dbid_cache(void); extern HASHACTION check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message, TimestampTz *last_overflow_report); +extern HASHACTION check_hash_fullness_num(HTAB *hashp, pg_atomic_uint32 *counter, int max_size, + const char *warning_message, TimestampTz *last_overflow_report); bool SPI_push_cond_and_connect(void); void SPI_finish_and_pop_cond(bool pushed); #endif diff --git a/src/diskquota_utility.c b/src/diskquota_utility.c index 43d0b0a1..84aa1104 100644 --- a/src/diskquota_utility.c +++ b/src/diskquota_utility.c @@ -1681,6 +1681,33 @@ check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message, Time return HASH_FIND; } +HASHACTION +check_hash_fullness_num(HTAB *hashp, pg_atomic_uint32 *counter, int max_size, const char *warning_message, + TimestampTz *last_overflow_report) +{ + uint32 num_entries = pg_atomic_read_u32(counter); + + if (num_entries < max_size) + { + (void)pg_atomic_add_fetch_u32(counter, 1); + return HASH_ENTER; + } + + if (num_entries == max_size) + { + TimestampTz current_time = GetCurrentTimestamp(); + + if (*last_overflow_report == 0 || TimestampDifferenceExceeds(*last_overflow_report, current_time, + diskquota_hashmap_overflow_report_timeout * 1000)) + { + ereport(WARNING, (errmsg("[diskquota] %s", warning_message))); + *last_overflow_report = current_time; + } + } + + return HASH_FIND; +} + bool SPI_push_cond_and_connect(void) { diff --git a/src/quotamodel.c b/src/quotamodel.c index ba0ab3ac..046da872 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -84,6 +84,9 @@ extern int diskquota_max_table_segments; extern int diskquota_max_monitored_databases; extern int diskquota_max_quota_probes; extern int diskquota_max_local_reject_entries; + +extern pg_atomic_uint32 *diskquota_table_size_entry_num; +extern pg_atomic_uint32 *diskquota_quota_info_entry_num; /* * local cache of table disk size and corresponding schema and owner. * @@ -264,8 +267,8 @@ update_size_for_quota(int64 size, QuotaType type, Oid *keys, int16 segid) memcpy(key.keys, keys, quota_key_num[type] * sizeof(Oid)); key.type = type; key.segid = segid; - action = check_hash_fullness(quota_info_map, diskquota_max_quota_probes, quota_info_map_warning, - quota_info_map_last_overflow_report); + action = check_hash_fullness_num(quota_info_map, diskquota_quota_info_entry_num, diskquota_max_quota_probes, + quota_info_map_warning, quota_info_map_last_overflow_report); entry = hash_search(quota_info_map, &key, action, &found); /* If the number of quota exceeds the limit, entry will be NULL */ if (entry == NULL) return; @@ -291,8 +294,8 @@ update_limit_for_quota(int64 limit, float segratio, QuotaType type, Oid *keys) memcpy(key.keys, keys, quota_key_num[type] * sizeof(Oid)); key.type = type; key.segid = i; - action = check_hash_fullness(quota_info_map, diskquota_max_quota_probes, quota_info_map_warning, - quota_info_map_last_overflow_report); + action = check_hash_fullness_num(quota_info_map, diskquota_quota_info_entry_num, diskquota_max_quota_probes, + quota_info_map_warning, quota_info_map_last_overflow_report); entry = hash_search(quota_info_map, &key, action, &found); /* If the number of quota exceeds the limit, entry will be NULL */ if (entry == NULL) continue; @@ -356,6 +359,7 @@ refresh_quota_info_map(void) if (!HeapTupleIsValid(tuple)) { hash_search(quota_info_map, &entry->key, HASH_REMOVE, NULL); + pg_atomic_fetch_sub_u32(diskquota_quota_info_entry_num, 1); removed = true; break; } @@ -545,6 +549,8 @@ DiskQuotaShmemSize(void) if (IS_QUERY_DISPATCHER()) { size = add_size(size, diskquota_launcher_shmem_size()); + size = add_size(size, sizeof(pg_atomic_uint32)); // diskquota_table_size_entry_num + size = add_size(size, sizeof(pg_atomic_uint32)); // diskquota_quota_info_entry_num size = add_size(size, diskquota_worker_shmem_size() * diskquota_max_monitored_databases); } @@ -637,6 +643,7 @@ vacuum_disk_quota_model(uint32 id) while ((tsentry = hash_seq_search(&iter)) != NULL) { hash_search(table_size_map, &tsentry->key, HASH_REMOVE, NULL); + pg_atomic_fetch_sub_u32(diskquota_table_size_entry_num, 1); } format_name("TableSizeEntrymap_last_overflow_report", id, &str); @@ -670,6 +677,7 @@ vacuum_disk_quota_model(uint32 id) while ((qentry = hash_seq_search(&iter)) != NULL) { hash_search(quota_info_map, &qentry->key, HASH_REMOVE, NULL); + pg_atomic_fetch_sub_u32(diskquota_quota_info_entry_num, 1); } format_name("QuotaInfoMap_last_overflow_report", id, &str); quota_info_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); @@ -902,10 +910,11 @@ static TableSizeEntry * get_table_size_map_entry(Oid oid, int16 segid) { bool found; - TableSizeEntryKey key = {.reloid = oid, .id = TableSizeEntryId(segid)}; - HASHACTION action = check_hash_fullness(table_size_map, MAX_NUM_TABLE_SIZE_ENTRIES, table_size_map_warning, - table_size_map_last_overflow_report); - TableSizeEntry *tsentry = hash_search(table_size_map, &key, action, &found); + TableSizeEntryKey key = {.reloid = oid, .id = TableSizeEntryId(segid)}; + HASHACTION action = + check_hash_fullness_num(table_size_map, diskquota_table_size_entry_num, MAX_NUM_TABLE_SIZE_ENTRIES, + table_size_map_warning, table_size_map_last_overflow_report); + TableSizeEntry *tsentry = hash_search(table_size_map, &key, action, &found); if (!found && tsentry != NULL) { @@ -1242,6 +1251,7 @@ flush_to_table_size(void) if (!get_table_size_entry_flag(tsentry, TABLE_EXIST)) { hash_search(table_size_map, &tsentry->key, HASH_REMOVE, NULL); + pg_atomic_fetch_sub_u32(diskquota_table_size_entry_num, 1); } } From 0636aaaef1bd9cdf6a14191d8558b623fdc389bc Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 4 Dec 2025 10:10:15 +0500 Subject: [PATCH 02/41] fix test_many_active_tables --- .../expected/test_many_active_tables.out | 508 +----------------- tests/regress/sql/test_many_active_tables.sql | 8 +- 2 files changed, 8 insertions(+), 508 deletions(-) diff --git a/tests/regress/expected/test_many_active_tables.out b/tests/regress/expected/test_many_active_tables.out index 8bf81587..09f87c8a 100644 --- a/tests/regress/expected/test_many_active_tables.out +++ b/tests/regress/expected/test_many_active_tables.out @@ -1,6 +1,6 @@ CREATE TABLE t1 (pk int, val int) DISTRIBUTED BY (pk) -PARTITION BY RANGE (pk) (START (1) END (1000) EVERY (1)); +PARTITION BY RANGE (pk) (START (1) END (500) EVERY (1)); NOTICE: CREATE TABLE will create partition "t1_1_prt_1" for table "t1" NOTICE: CREATE TABLE will create partition "t1_1_prt_2" for table "t1" NOTICE: CREATE TABLE will create partition "t1_1_prt_3" for table "t1" @@ -500,516 +500,16 @@ NOTICE: CREATE TABLE will create partition "t1_1_prt_496" for table "t1" NOTICE: CREATE TABLE will create partition "t1_1_prt_497" for table "t1" NOTICE: CREATE TABLE will create partition "t1_1_prt_498" for table "t1" NOTICE: CREATE TABLE will create partition "t1_1_prt_499" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_500" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_501" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_502" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_503" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_504" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_505" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_506" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_507" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_508" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_509" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_510" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_511" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_512" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_513" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_514" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_515" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_516" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_517" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_518" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_519" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_520" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_521" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_522" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_523" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_524" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_525" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_526" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_527" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_528" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_529" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_530" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_531" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_532" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_533" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_534" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_535" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_536" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_537" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_538" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_539" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_540" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_541" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_542" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_543" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_544" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_545" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_546" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_547" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_548" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_549" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_550" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_551" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_552" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_553" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_554" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_555" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_556" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_557" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_558" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_559" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_560" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_561" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_562" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_563" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_564" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_565" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_566" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_567" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_568" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_569" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_570" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_571" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_572" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_573" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_574" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_575" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_576" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_577" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_578" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_579" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_580" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_581" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_582" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_583" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_584" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_585" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_586" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_587" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_588" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_589" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_590" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_591" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_592" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_593" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_594" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_595" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_596" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_597" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_598" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_599" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_600" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_601" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_602" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_603" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_604" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_605" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_606" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_607" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_608" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_609" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_610" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_611" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_612" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_613" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_614" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_615" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_616" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_617" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_618" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_619" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_620" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_621" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_622" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_623" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_624" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_625" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_626" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_627" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_628" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_629" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_630" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_631" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_632" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_633" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_634" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_635" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_636" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_637" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_638" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_639" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_640" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_641" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_642" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_643" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_644" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_645" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_646" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_647" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_648" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_649" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_650" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_651" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_652" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_653" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_654" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_655" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_656" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_657" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_658" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_659" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_660" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_661" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_662" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_663" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_664" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_665" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_666" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_667" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_668" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_669" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_670" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_671" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_672" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_673" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_674" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_675" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_676" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_677" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_678" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_679" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_680" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_681" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_682" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_683" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_684" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_685" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_686" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_687" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_688" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_689" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_690" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_691" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_692" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_693" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_694" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_695" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_696" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_697" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_698" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_699" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_700" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_701" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_702" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_703" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_704" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_705" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_706" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_707" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_708" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_709" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_710" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_711" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_712" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_713" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_714" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_715" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_716" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_717" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_718" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_719" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_720" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_721" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_722" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_723" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_724" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_725" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_726" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_727" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_728" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_729" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_730" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_731" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_732" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_733" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_734" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_735" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_736" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_737" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_738" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_739" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_740" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_741" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_742" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_743" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_744" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_745" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_746" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_747" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_748" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_749" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_750" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_751" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_752" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_753" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_754" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_755" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_756" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_757" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_758" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_759" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_760" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_761" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_762" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_763" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_764" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_765" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_766" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_767" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_768" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_769" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_770" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_771" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_772" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_773" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_774" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_775" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_776" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_777" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_778" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_779" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_780" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_781" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_782" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_783" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_784" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_785" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_786" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_787" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_788" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_789" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_790" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_791" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_792" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_793" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_794" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_795" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_796" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_797" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_798" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_799" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_800" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_801" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_802" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_803" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_804" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_805" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_806" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_807" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_808" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_809" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_810" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_811" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_812" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_813" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_814" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_815" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_816" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_817" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_818" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_819" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_820" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_821" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_822" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_823" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_824" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_825" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_826" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_827" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_828" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_829" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_830" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_831" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_832" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_833" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_834" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_835" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_836" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_837" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_838" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_839" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_840" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_841" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_842" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_843" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_844" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_845" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_846" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_847" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_848" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_849" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_850" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_851" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_852" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_853" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_854" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_855" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_856" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_857" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_858" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_859" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_860" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_861" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_862" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_863" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_864" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_865" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_866" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_867" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_868" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_869" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_870" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_871" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_872" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_873" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_874" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_875" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_876" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_877" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_878" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_879" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_880" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_881" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_882" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_883" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_884" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_885" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_886" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_887" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_888" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_889" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_890" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_891" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_892" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_893" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_894" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_895" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_896" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_897" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_898" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_899" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_900" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_901" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_902" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_903" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_904" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_905" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_906" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_907" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_908" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_909" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_910" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_911" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_912" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_913" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_914" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_915" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_916" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_917" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_918" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_919" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_920" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_921" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_922" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_923" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_924" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_925" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_926" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_927" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_928" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_929" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_930" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_931" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_932" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_933" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_934" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_935" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_936" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_937" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_938" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_939" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_940" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_941" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_942" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_943" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_944" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_945" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_946" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_947" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_948" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_949" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_950" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_951" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_952" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_953" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_954" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_955" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_956" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_957" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_958" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_959" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_960" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_961" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_962" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_963" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_964" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_965" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_966" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_967" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_968" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_969" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_970" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_971" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_972" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_973" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_974" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_975" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_976" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_977" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_978" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_979" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_980" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_981" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_982" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_983" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_984" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_985" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_986" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_987" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_988" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_989" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_990" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_991" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_992" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_993" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_994" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_995" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_996" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_997" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_998" for table "t1" -NOTICE: CREATE TABLE will create partition "t1_1_prt_999" for table "t1" INSERT INTO t1 SELECT pk, val -FROM generate_series(1, 10000) AS val, generate_series(1, 999) AS pk; +FROM generate_series(1, 10000) AS val, generate_series(1, 499) AS pk; SELECT diskquota.wait_for_worker_new_epoch(); wait_for_worker_new_epoch --------------------------- t (1 row) -SELECT count(*) >= 999 FROM diskquota.table_size WHERE size > 0; +SELECT count(*) >= 499 FROM diskquota.table_size WHERE size > 0; ?column? ---------- t @@ -1022,7 +522,7 @@ SELECT diskquota.wait_for_worker_new_epoch(); t (1 row) -SELECT count(*) < 999 FROM diskquota.table_size WHERE size > 0; +SELECT count(*) < 499 FROM diskquota.table_size WHERE size > 0; ?column? ---------- t diff --git a/tests/regress/sql/test_many_active_tables.sql b/tests/regress/sql/test_many_active_tables.sql index 4c617cf6..7531725b 100644 --- a/tests/regress/sql/test_many_active_tables.sql +++ b/tests/regress/sql/test_many_active_tables.sql @@ -1,17 +1,17 @@ CREATE TABLE t1 (pk int, val int) DISTRIBUTED BY (pk) -PARTITION BY RANGE (pk) (START (1) END (1000) EVERY (1)); +PARTITION BY RANGE (pk) (START (1) END (500) EVERY (1)); INSERT INTO t1 SELECT pk, val -FROM generate_series(1, 10000) AS val, generate_series(1, 999) AS pk; +FROM generate_series(1, 10000) AS val, generate_series(1, 499) AS pk; SELECT diskquota.wait_for_worker_new_epoch(); -SELECT count(*) >= 999 FROM diskquota.table_size WHERE size > 0; +SELECT count(*) >= 499 FROM diskquota.table_size WHERE size > 0; DROP TABLE t1; SELECT diskquota.wait_for_worker_new_epoch(); -SELECT count(*) < 999 FROM diskquota.table_size WHERE size > 0; +SELECT count(*) < 499 FROM diskquota.table_size WHERE size > 0; From 26d0a0e220cfc093cb149259f06818f7e4319e26 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 4 Dec 2025 15:59:48 +0500 Subject: [PATCH 03/41] Fix shared memory allocation and usage in diskquota --- src/diskquota.c | 10 ++++++ src/gp_activetable.c | 12 +++++++ src/quotamodel.c | 79 ++++++++++++++++++++++++++++++++++++++++++++ src/relation_cache.c | 12 +++++++ 4 files changed, 113 insertions(+) diff --git a/src/diskquota.c b/src/diskquota.c index aa706f40..93ca525b 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -105,6 +105,10 @@ static DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem; */ BackgroundWorkerHandle **bgworker_handles; +#ifdef USE_ASSERT_CHECKING +extern pg_atomic_uint32 *diskquota_shmem_size; +#endif + typedef enum { SUCCESS, @@ -1734,6 +1738,12 @@ init_launcher_shmem() bool found; DiskquotaLauncherShmem = (DiskquotaLauncherShmemStruct *)ShmemInitStruct("Diskquota launcher Data", diskquota_launcher_shmem_size(), &found); + +#ifdef USE_ASSERT_CHECKING + if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, diskquota_launcher_shmem_size()); + if (found) elog(WARNING, "DiskquotaLauncherShmem found!"); +#endif + memset(DiskquotaLauncherShmem, 0, diskquota_launcher_shmem_size()); if (!found) { diff --git a/src/gp_activetable.c b/src/gp_activetable.c index bf34e2ae..629d1a16 100644 --- a/src/gp_activetable.c +++ b/src/gp_activetable.c @@ -79,6 +79,10 @@ static file_truncate_hook_type prev_file_truncate_hook = NULL; static file_unlink_hook_type prev_file_unlink_hook = NULL; static object_access_hook_type prev_object_access_hook = NULL; +#ifdef USE_ASSERT_CHECKING +extern pg_atomic_uint32 *diskquota_shmem_size; +#endif + static void active_table_hook_smgrcreate(RelFileNodeBackend rnode); static void active_table_hook_smgrextend(RelFileNodeBackend rnode); static void active_table_hook_smgrtruncate(RelFileNodeBackend rnode); @@ -114,11 +118,19 @@ init_shm_worker_active_tables(void) active_tables_map = DiskquotaShmemInitHash("active_tables", diskquota_max_active_tables, diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); +#ifdef USE_ASSERT_CHECKING + pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaActiveTableFileEntry))); +#endif + memset(&ctl, 0, sizeof(ctl)); ctl.keysize = sizeof(Oid); ctl.entrysize = sizeof(Oid); altered_reloid_cache = DiskquotaShmemInitHash("altered_reloid_cache", diskquota_max_active_tables, diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_OID_HASH); + +#ifdef USE_ASSERT_CHECKING + pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(Oid))); +#endif } /* diff --git a/src/quotamodel.c b/src/quotamodel.c index ba0ab3ac..181786b6 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -210,6 +210,10 @@ static const char *local_disk_quota_reject_map_warning = static shmem_startup_hook_type prev_shmem_startup_hook = NULL; +#ifdef USE_ASSERT_CHECKING +pg_atomic_uint32 *diskquota_shmem_size; +#endif + /* functions to maintain the quota maps */ static void update_size_for_quota(int64 size, QuotaType type, Oid *keys, int16 segid); static void update_limit_for_quota(int64 limit, float segratio, QuotaType type, Oid *keys); @@ -439,8 +443,19 @@ disk_quota_shmem_startup(void) if (prev_shmem_startup_hook) (*prev_shmem_startup_hook)(); +#ifdef USE_ASSERT_CHECKING + elog(WARNING, "diskquota_shmem_size = %li", DiskQuotaShmemSize()); +#endif + LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE); +#ifdef USE_ASSERT_CHECKING + diskquota_shmem_size = + ShmemInitStruct("diskquota_shmem_size", sizeof(pg_atomic_uint32), &found); + if (!found) pg_atomic_init_u32(diskquota_shmem_size, DiskQuotaShmemSize()); + if (found) elog(WARNING, "diskquota_shmem_size found!"); +#endif + init_lwlocks(); /* @@ -452,6 +467,11 @@ disk_quota_shmem_startup(void) extension_ddl_message = ShmemInitStruct("disk_quota_extension_ddl_message", sizeof(ExtensionDDLMessage), &found); if (!found) memset((void *)extension_ddl_message, 0, sizeof(ExtensionDDLMessage)); +#ifdef USE_ASSERT_CHECKING + if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, sizeof(ExtensionDDLMessage)); + if (found) elog(WARNING, "extension_ddl_message found!"); +#endif + memset(&hash_ctl, 0, sizeof(hash_ctl)); hash_ctl.keysize = sizeof(RejectMapEntry); hash_ctl.entrysize = sizeof(GlobalRejectMapEntry); @@ -459,6 +479,10 @@ disk_quota_shmem_startup(void) DiskquotaShmemInitHash("rejectmap whose quota limitation is reached", diskquota_max_local_reject_entries, MAX_DISK_QUOTA_REJECT_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); +#ifdef USE_ASSERT_CHECKING + pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(MAX_DISK_QUOTA_REJECT_ENTRIES, sizeof(GlobalRejectMapEntry))); +#endif + init_shm_worker_active_tables(); init_shm_worker_relation_cache(); @@ -470,8 +494,17 @@ disk_quota_shmem_startup(void) monitored_dbid_cache = DiskquotaShmemInitHash("table oid cache which shoud tracking", diskquota_max_monitored_databases, diskquota_max_monitored_databases, &hash_ctl, HASH_ELEM, DISKQUOTA_OID_HASH); + +#ifdef USE_ASSERT_CHECKING + pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(diskquota_max_monitored_databases, sizeof(MonitorDBEntry))); +#endif + init_launcher_shmem(); LWLockRelease(AddinShmemInitLock); + +#ifdef USE_ASSERT_CHECKING + elog(WARNING, "diskquota_shmem_size = %i", pg_atomic_read_u32(diskquota_shmem_size)); +#endif } /* @@ -534,6 +567,11 @@ DiskQuotaShmemSize(void) { Size size; size = sizeof(ExtensionDDLMessage); + +#ifdef USE_ASSERT_CHECKING + size = add_size(size, sizeof(pg_atomic_uint32)); +#endif + size = add_size(size, hash_estimate_size(MAX_DISK_QUOTA_REJECT_ENTRIES, sizeof(GlobalRejectMapEntry))); size = add_size(size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaActiveTableEntry))); size = add_size(size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelationCacheEntry))); @@ -563,16 +601,32 @@ init_disk_quota_model(uint32 id) bool found; initStringInfo(&str); +#ifdef USE_ASSERT_CHECKING + elog(WARNING, "diskquota_shmem_size = %i", pg_atomic_read_u32(diskquota_shmem_size)); +#endif + + LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE); + format_name("TableSizeEntrymap", id, &str); memset(&hash_ctl, 0, sizeof(hash_ctl)); hash_ctl.keysize = sizeof(TableSizeEntryKey); hash_ctl.entrysize = sizeof(TableSizeEntry); table_size_map = DiskquotaShmemInitHash(str.data, INIT_NUM_TABLE_SIZE_ENTRIES, MAX_NUM_TABLE_SIZE_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); + +#ifdef USE_ASSERT_CHECKING + pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, sizeof(TableSizeEntry))); +#endif + format_name("TableSizeEntrymap_last_overflow_report", id, &str); table_size_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); if (!found) *table_size_map_last_overflow_report = 0; +#ifdef USE_ASSERT_CHECKING + if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, sizeof(TimestampTz)); + if (found) elog(WARNING, "table_size_map_last_overflow_report found!"); +#endif + /* for localrejectmap */ /* WARNNING: The max length of name of the map is 48 */ format_name("localrejectmap", id, &str); @@ -583,10 +637,19 @@ init_disk_quota_model(uint32 id) DiskquotaShmemInitHash(str.data, diskquota_max_local_reject_entries, diskquota_max_local_reject_entries, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); +#ifdef USE_ASSERT_CHECKING + pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(diskquota_max_local_reject_entries, sizeof(LocalRejectMapEntry))); +#endif + format_name("localrejectmap_last_overflow_report", id, &str); local_disk_quota_reject_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); if (!found) *local_disk_quota_reject_map_last_overflow_report = 0; +#ifdef USE_ASSERT_CHECKING + if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, sizeof(TimestampTz)); + if (found) elog(WARNING, "local_disk_quota_reject_map_last_overflow_report found!"); +#endif + /* for quota_info_map */ format_name("QuotaInfoMap", id, &str); memset(&hash_ctl, 0, sizeof(hash_ctl)); @@ -594,11 +657,27 @@ init_disk_quota_model(uint32 id) hash_ctl.keysize = sizeof(QuotaInfoEntryKey); quota_info_map = DiskquotaShmemInitHash(str.data, INIT_QUOTA_MAP_ENTRIES, MAX_QUOTA_MAP_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); + +#ifdef USE_ASSERT_CHECKING + pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, sizeof(QuotaInfoEntry))); +#endif + format_name("QuotaInfoMap_last_overflow_report", id, &str); quota_info_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); if (!found) *quota_info_map_last_overflow_report = 0; +#ifdef USE_ASSERT_CHECKING + if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, sizeof(TimestampTz)); + if (found) elog(WARNING, "quota_info_map_last_overflow_report found!"); +#endif + pfree(str.data); + + LWLockRelease(AddinShmemInitLock); + +#ifdef USE_ASSERT_CHECKING + elog(WARNING, "diskquota_shmem_size = %i", pg_atomic_read_u32(diskquota_shmem_size)); +#endif } /* diff --git a/src/relation_cache.c b/src/relation_cache.c index b5624c42..c0036ca5 100644 --- a/src/relation_cache.c +++ b/src/relation_cache.c @@ -42,6 +42,10 @@ static const char *relid_cache_warning = "the number of relid cache entries reached the limit, please increase " "the GUC value for diskquota.max_active_tables."; +#ifdef USE_ASSERT_CHECKING +extern pg_atomic_uint32 *diskquota_shmem_size; +#endif + static void update_relation_entry(Oid relid, DiskQuotaRelationCacheEntry *relation_entry, DiskQuotaRelidCacheEntry *relid_entry); @@ -58,11 +62,19 @@ init_shm_worker_relation_cache(void) relation_cache = DiskquotaShmemInitHash("relation_cache", diskquota_max_active_tables, diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_OID_HASH); +#ifdef USE_ASSERT_CHECKING + pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelationCacheEntry))); +#endif + memset(&ctl, 0, sizeof(ctl)); ctl.keysize = sizeof(Oid); ctl.entrysize = sizeof(DiskQuotaRelidCacheEntry); relid_cache = DiskquotaShmemInitHash("relid_cache", diskquota_max_active_tables, diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_OID_HASH); + +#ifdef USE_ASSERT_CHECKING + pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelidCacheEntry))); +#endif } Oid From 5a868315b138b4e0009c0f1011667d273836d3fd Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Fri, 5 Dec 2025 09:36:42 +0500 Subject: [PATCH 04/41] fix --- src/gp_activetable.c | 3 ++- src/quotamodel.c | 45 +++++++++++++++++++++++++------------------- src/relation_cache.c | 6 ++++-- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/gp_activetable.c b/src/gp_activetable.c index 629d1a16..e041ae5d 100644 --- a/src/gp_activetable.c +++ b/src/gp_activetable.c @@ -119,7 +119,8 @@ init_shm_worker_active_tables(void) diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaActiveTableFileEntry))); + pg_atomic_sub_fetch_u32(diskquota_shmem_size, + hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaActiveTableFileEntry))); #endif memset(&ctl, 0, sizeof(ctl)); diff --git a/src/quotamodel.c b/src/quotamodel.c index 181786b6..7efc49d6 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -450,8 +450,7 @@ disk_quota_shmem_startup(void) LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE); #ifdef USE_ASSERT_CHECKING - diskquota_shmem_size = - ShmemInitStruct("diskquota_shmem_size", sizeof(pg_atomic_uint32), &found); + diskquota_shmem_size = ShmemInitStruct("diskquota_shmem_size", sizeof(pg_atomic_uint32), &found); if (!found) pg_atomic_init_u32(diskquota_shmem_size, DiskQuotaShmemSize()); if (found) elog(WARNING, "diskquota_shmem_size found!"); #endif @@ -480,7 +479,8 @@ disk_quota_shmem_startup(void) MAX_DISK_QUOTA_REJECT_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(MAX_DISK_QUOTA_REJECT_ENTRIES, sizeof(GlobalRejectMapEntry))); + pg_atomic_sub_fetch_u32(diskquota_shmem_size, + hash_estimate_size(MAX_DISK_QUOTA_REJECT_ENTRIES, sizeof(GlobalRejectMapEntry))); #endif init_shm_worker_active_tables(); @@ -496,10 +496,11 @@ disk_quota_shmem_startup(void) diskquota_max_monitored_databases, &hash_ctl, HASH_ELEM, DISKQUOTA_OID_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(diskquota_max_monitored_databases, sizeof(MonitorDBEntry))); + pg_atomic_sub_fetch_u32(diskquota_shmem_size, + hash_estimate_size(diskquota_max_monitored_databases, sizeof(struct MonitorDBEntryStruct))); #endif - init_launcher_shmem(); + if (IS_QUERY_DISPATCHER()) init_launcher_shmem(); LWLockRelease(AddinShmemInitLock); #ifdef USE_ASSERT_CHECKING @@ -548,10 +549,10 @@ static Size diskquota_worker_shmem_size() { Size size; - size = hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES / diskquota_max_monitored_databases + 100, - sizeof(TableSizeEntry)); - size = add_size(size, hash_estimate_size(diskquota_max_local_reject_entries, sizeof(LocalRejectMapEntry))); - size = add_size(size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, sizeof(QuotaInfoEntry))); + size = hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, sizeof(TableSizeEntry)); // table_size_map + size = add_size(size, hash_estimate_size(diskquota_max_local_reject_entries, + sizeof(LocalRejectMapEntry))); // local_disk_quota_reject_map + size = add_size(size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, sizeof(QuotaInfoEntry))); // quota_info_map size = add_size(size, sizeof(TimestampTz)); // table_size_map_last_overflow_report size = add_size(size, sizeof(TimestampTz)); // local_disk_quota_reject_map_last_overflow_report size = add_size(size, sizeof(TimestampTz)); // quota_info_map_last_overflow_report @@ -566,23 +567,27 @@ static Size DiskQuotaShmemSize(void) { Size size; - size = sizeof(ExtensionDDLMessage); + size = sizeof(ExtensionDDLMessage); // extension_ddl_message #ifdef USE_ASSERT_CHECKING - size = add_size(size, sizeof(pg_atomic_uint32)); + size = add_size(size, sizeof(pg_atomic_uint32)); // diskquota_shmem_size #endif - size = add_size(size, hash_estimate_size(MAX_DISK_QUOTA_REJECT_ENTRIES, sizeof(GlobalRejectMapEntry))); - size = add_size(size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaActiveTableEntry))); - size = add_size(size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelationCacheEntry))); - size = add_size(size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelidCacheEntry))); - size = add_size(size, hash_estimate_size(diskquota_max_active_tables, sizeof(Oid))); + size = add_size(size, hash_estimate_size(MAX_DISK_QUOTA_REJECT_ENTRIES, + sizeof(GlobalRejectMapEntry))); // disk_quota_reject_map + size = add_size(size, hash_estimate_size(diskquota_max_active_tables, + sizeof(DiskQuotaActiveTableFileEntry))); // active_tables_map + size = add_size(size, hash_estimate_size(diskquota_max_active_tables, + sizeof(DiskQuotaRelationCacheEntry))); // relation_cache + size = add_size(size, + hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelidCacheEntry))); // relid_cache + size = add_size(size, hash_estimate_size(diskquota_max_active_tables, sizeof(Oid))); // altered_reloid_cache size = add_size(size, hash_estimate_size(diskquota_max_monitored_databases, sizeof(struct MonitorDBEntryStruct))); // monitored_dbid_cache if (IS_QUERY_DISPATCHER()) { - size = add_size(size, diskquota_launcher_shmem_size()); + size = add_size(size, diskquota_launcher_shmem_size()); // DiskquotaLauncherShmem size = add_size(size, diskquota_worker_shmem_size() * diskquota_max_monitored_databases); } @@ -615,7 +620,8 @@ init_disk_quota_model(uint32 id) &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, sizeof(TableSizeEntry))); + pg_atomic_sub_fetch_u32(diskquota_shmem_size, + hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, sizeof(TableSizeEntry))); #endif format_name("TableSizeEntrymap_last_overflow_report", id, &str); @@ -638,7 +644,8 @@ init_disk_quota_model(uint32 id) &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(diskquota_max_local_reject_entries, sizeof(LocalRejectMapEntry))); + pg_atomic_sub_fetch_u32(diskquota_shmem_size, + hash_estimate_size(diskquota_max_local_reject_entries, sizeof(LocalRejectMapEntry))); #endif format_name("localrejectmap_last_overflow_report", id, &str); diff --git a/src/relation_cache.c b/src/relation_cache.c index c0036ca5..d5e81b4f 100644 --- a/src/relation_cache.c +++ b/src/relation_cache.c @@ -63,7 +63,8 @@ init_shm_worker_relation_cache(void) &ctl, HASH_ELEM, DISKQUOTA_OID_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelationCacheEntry))); + pg_atomic_sub_fetch_u32(diskquota_shmem_size, + hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelationCacheEntry))); #endif memset(&ctl, 0, sizeof(ctl)); @@ -73,7 +74,8 @@ init_shm_worker_relation_cache(void) HASH_ELEM, DISKQUOTA_OID_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelidCacheEntry))); + pg_atomic_sub_fetch_u32(diskquota_shmem_size, + hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelidCacheEntry))); #endif } From 393f5ab12915710a81475bd5e805228240dbbfa3 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Fri, 5 Dec 2025 09:57:13 +0500 Subject: [PATCH 05/41] assert --- src/quotamodel.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index 7efc49d6..59a2b26d 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -243,6 +243,8 @@ static bool get_table_size_entry_flag(TableSizeEntry *entry, TableSizeEntryFlag static void reset_table_size_entry_flag(TableSizeEntry *entry, TableSizeEntryFlag flag); static void set_table_size_entry_flag(TableSizeEntry *entry, TableSizeEntryFlag flag); +static Size diskquota_worker_shmem_size(); + typedef struct { ArrayBuildState *tableids; @@ -451,7 +453,7 @@ disk_quota_shmem_startup(void) #ifdef USE_ASSERT_CHECKING diskquota_shmem_size = ShmemInitStruct("diskquota_shmem_size", sizeof(pg_atomic_uint32), &found); - if (!found) pg_atomic_init_u32(diskquota_shmem_size, DiskQuotaShmemSize()); + if (!found) pg_atomic_init_u32(diskquota_shmem_size, DiskQuotaShmemSize() - sizeof(pg_atomic_uint32)); if (found) elog(WARNING, "diskquota_shmem_size found!"); #endif @@ -505,6 +507,11 @@ disk_quota_shmem_startup(void) #ifdef USE_ASSERT_CHECKING elog(WARNING, "diskquota_shmem_size = %i", pg_atomic_read_u32(diskquota_shmem_size)); + if (IS_QUERY_DISPATCHER()) + Assert(pg_atomic_read_u32(diskquota_shmem_size) == + diskquota_worker_shmem_size() * diskquota_max_monitored_databases); + else + Assert(pg_atomic_read_u32(diskquota_shmem_size) == 0); #endif } @@ -608,6 +615,7 @@ init_disk_quota_model(uint32 id) #ifdef USE_ASSERT_CHECKING elog(WARNING, "diskquota_shmem_size = %i", pg_atomic_read_u32(diskquota_shmem_size)); + Assert(pg_atomic_read_u32(diskquota_shmem_size) >= 0); #endif LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE); @@ -684,6 +692,7 @@ init_disk_quota_model(uint32 id) #ifdef USE_ASSERT_CHECKING elog(WARNING, "diskquota_shmem_size = %i", pg_atomic_read_u32(diskquota_shmem_size)); + Assert(pg_atomic_read_u32(diskquota_shmem_size) >= 0); #endif } From 899e80904a05847288c0c52afde480f44712f52d Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Fri, 5 Dec 2025 09:59:57 +0500 Subject: [PATCH 06/41] rm warning --- src/diskquota.c | 1 - src/quotamodel.c | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/src/diskquota.c b/src/diskquota.c index 93ca525b..5b48bf56 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -1741,7 +1741,6 @@ init_launcher_shmem() #ifdef USE_ASSERT_CHECKING if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, diskquota_launcher_shmem_size()); - if (found) elog(WARNING, "DiskquotaLauncherShmem found!"); #endif memset(DiskquotaLauncherShmem, 0, diskquota_launcher_shmem_size()); diff --git a/src/quotamodel.c b/src/quotamodel.c index 59a2b26d..73be8cd8 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -445,16 +445,11 @@ disk_quota_shmem_startup(void) if (prev_shmem_startup_hook) (*prev_shmem_startup_hook)(); -#ifdef USE_ASSERT_CHECKING - elog(WARNING, "diskquota_shmem_size = %li", DiskQuotaShmemSize()); -#endif - LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE); #ifdef USE_ASSERT_CHECKING diskquota_shmem_size = ShmemInitStruct("diskquota_shmem_size", sizeof(pg_atomic_uint32), &found); if (!found) pg_atomic_init_u32(diskquota_shmem_size, DiskQuotaShmemSize() - sizeof(pg_atomic_uint32)); - if (found) elog(WARNING, "diskquota_shmem_size found!"); #endif init_lwlocks(); @@ -470,7 +465,6 @@ disk_quota_shmem_startup(void) #ifdef USE_ASSERT_CHECKING if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, sizeof(ExtensionDDLMessage)); - if (found) elog(WARNING, "extension_ddl_message found!"); #endif memset(&hash_ctl, 0, sizeof(hash_ctl)); @@ -506,7 +500,6 @@ disk_quota_shmem_startup(void) LWLockRelease(AddinShmemInitLock); #ifdef USE_ASSERT_CHECKING - elog(WARNING, "diskquota_shmem_size = %i", pg_atomic_read_u32(diskquota_shmem_size)); if (IS_QUERY_DISPATCHER()) Assert(pg_atomic_read_u32(diskquota_shmem_size) == diskquota_worker_shmem_size() * diskquota_max_monitored_databases); @@ -614,7 +607,6 @@ init_disk_quota_model(uint32 id) initStringInfo(&str); #ifdef USE_ASSERT_CHECKING - elog(WARNING, "diskquota_shmem_size = %i", pg_atomic_read_u32(diskquota_shmem_size)); Assert(pg_atomic_read_u32(diskquota_shmem_size) >= 0); #endif @@ -638,7 +630,6 @@ init_disk_quota_model(uint32 id) #ifdef USE_ASSERT_CHECKING if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, sizeof(TimestampTz)); - if (found) elog(WARNING, "table_size_map_last_overflow_report found!"); #endif /* for localrejectmap */ @@ -662,7 +653,6 @@ init_disk_quota_model(uint32 id) #ifdef USE_ASSERT_CHECKING if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, sizeof(TimestampTz)); - if (found) elog(WARNING, "local_disk_quota_reject_map_last_overflow_report found!"); #endif /* for quota_info_map */ @@ -683,7 +673,6 @@ init_disk_quota_model(uint32 id) #ifdef USE_ASSERT_CHECKING if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, sizeof(TimestampTz)); - if (found) elog(WARNING, "quota_info_map_last_overflow_report found!"); #endif pfree(str.data); @@ -691,7 +680,6 @@ init_disk_quota_model(uint32 id) LWLockRelease(AddinShmemInitLock); #ifdef USE_ASSERT_CHECKING - elog(WARNING, "diskquota_shmem_size = %i", pg_atomic_read_u32(diskquota_shmem_size)); Assert(pg_atomic_read_u32(diskquota_shmem_size) >= 0); #endif } From 0df528cf9f332693f60a9f6a455cb0227c292017 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Fri, 5 Dec 2025 10:04:45 +0500 Subject: [PATCH 07/41] void --- src/quotamodel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index 73be8cd8..17124051 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -243,7 +243,7 @@ static bool get_table_size_entry_flag(TableSizeEntry *entry, TableSizeEntryFlag static void reset_table_size_entry_flag(TableSizeEntry *entry, TableSizeEntryFlag flag); static void set_table_size_entry_flag(TableSizeEntry *entry, TableSizeEntryFlag flag); -static Size diskquota_worker_shmem_size(); +static Size diskquota_worker_shmem_size(void); typedef struct { @@ -546,7 +546,7 @@ init_lwlocks(void) } static Size -diskquota_worker_shmem_size() +diskquota_worker_shmem_size(void) { Size size; size = hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, sizeof(TableSizeEntry)); // table_size_map From 17da424854eb4f1650b50c9daa72e98fb638f970 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Fri, 5 Dec 2025 10:13:27 +0500 Subject: [PATCH 08/41] rm lock --- src/quotamodel.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index 17124051..175a2070 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -610,8 +610,6 @@ init_disk_quota_model(uint32 id) Assert(pg_atomic_read_u32(diskquota_shmem_size) >= 0); #endif - LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE); - format_name("TableSizeEntrymap", id, &str); memset(&hash_ctl, 0, sizeof(hash_ctl)); hash_ctl.keysize = sizeof(TableSizeEntryKey); @@ -677,8 +675,6 @@ init_disk_quota_model(uint32 id) pfree(str.data); - LWLockRelease(AddinShmemInitLock); - #ifdef USE_ASSERT_CHECKING Assert(pg_atomic_read_u32(diskquota_shmem_size) >= 0); #endif From f8411bcd179d0f05a0c19823b8a95356617657df Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Fri, 5 Dec 2025 10:45:34 +0500 Subject: [PATCH 09/41] 32 -> 64 --- src/diskquota.c | 4 ++-- src/gp_activetable.c | 6 +++--- src/quotamodel.c | 34 +++++++++++++++++----------------- src/relation_cache.c | 6 +++--- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/diskquota.c b/src/diskquota.c index 5b48bf56..9fe1ad98 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -106,7 +106,7 @@ static DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem; BackgroundWorkerHandle **bgworker_handles; #ifdef USE_ASSERT_CHECKING -extern pg_atomic_uint32 *diskquota_shmem_size; +extern pg_atomic_uint64 *diskquota_shmem_size; #endif typedef enum @@ -1740,7 +1740,7 @@ init_launcher_shmem() diskquota_launcher_shmem_size(), &found); #ifdef USE_ASSERT_CHECKING - if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, diskquota_launcher_shmem_size()); + if (!found) pg_atomic_sub_fetch_u64(diskquota_shmem_size, diskquota_launcher_shmem_size()); #endif memset(DiskquotaLauncherShmem, 0, diskquota_launcher_shmem_size()); diff --git a/src/gp_activetable.c b/src/gp_activetable.c index e041ae5d..4f34e1d6 100644 --- a/src/gp_activetable.c +++ b/src/gp_activetable.c @@ -80,7 +80,7 @@ static file_unlink_hook_type prev_file_unlink_hook = NULL; static object_access_hook_type prev_object_access_hook = NULL; #ifdef USE_ASSERT_CHECKING -extern pg_atomic_uint32 *diskquota_shmem_size; +extern pg_atomic_uint64 *diskquota_shmem_size; #endif static void active_table_hook_smgrcreate(RelFileNodeBackend rnode); @@ -119,7 +119,7 @@ init_shm_worker_active_tables(void) diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaActiveTableFileEntry))); #endif @@ -130,7 +130,7 @@ init_shm_worker_active_tables(void) diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_OID_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(Oid))); + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(Oid))); #endif } diff --git a/src/quotamodel.c b/src/quotamodel.c index 175a2070..00111ff9 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -211,7 +211,7 @@ static const char *local_disk_quota_reject_map_warning = static shmem_startup_hook_type prev_shmem_startup_hook = NULL; #ifdef USE_ASSERT_CHECKING -pg_atomic_uint32 *diskquota_shmem_size; +pg_atomic_uint64 *diskquota_shmem_size; #endif /* functions to maintain the quota maps */ @@ -448,8 +448,8 @@ disk_quota_shmem_startup(void) LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE); #ifdef USE_ASSERT_CHECKING - diskquota_shmem_size = ShmemInitStruct("diskquota_shmem_size", sizeof(pg_atomic_uint32), &found); - if (!found) pg_atomic_init_u32(diskquota_shmem_size, DiskQuotaShmemSize() - sizeof(pg_atomic_uint32)); + diskquota_shmem_size = ShmemInitStruct("diskquota_shmem_size", sizeof(pg_atomic_uint64), &found); + if (!found) pg_atomic_init_u64(diskquota_shmem_size, DiskQuotaShmemSize() - sizeof(pg_atomic_uint64)); #endif init_lwlocks(); @@ -464,7 +464,7 @@ disk_quota_shmem_startup(void) if (!found) memset((void *)extension_ddl_message, 0, sizeof(ExtensionDDLMessage)); #ifdef USE_ASSERT_CHECKING - if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, sizeof(ExtensionDDLMessage)); + if (!found) pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(ExtensionDDLMessage)); #endif memset(&hash_ctl, 0, sizeof(hash_ctl)); @@ -475,7 +475,7 @@ disk_quota_shmem_startup(void) MAX_DISK_QUOTA_REJECT_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(MAX_DISK_QUOTA_REJECT_ENTRIES, sizeof(GlobalRejectMapEntry))); #endif @@ -492,7 +492,7 @@ disk_quota_shmem_startup(void) diskquota_max_monitored_databases, &hash_ctl, HASH_ELEM, DISKQUOTA_OID_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(diskquota_max_monitored_databases, sizeof(struct MonitorDBEntryStruct))); #endif @@ -501,10 +501,10 @@ disk_quota_shmem_startup(void) #ifdef USE_ASSERT_CHECKING if (IS_QUERY_DISPATCHER()) - Assert(pg_atomic_read_u32(diskquota_shmem_size) == + Assert(pg_atomic_read_u64(diskquota_shmem_size) == diskquota_worker_shmem_size() * diskquota_max_monitored_databases); else - Assert(pg_atomic_read_u32(diskquota_shmem_size) == 0); + Assert(pg_atomic_read_u64(diskquota_shmem_size) == 0); #endif } @@ -570,7 +570,7 @@ DiskQuotaShmemSize(void) size = sizeof(ExtensionDDLMessage); // extension_ddl_message #ifdef USE_ASSERT_CHECKING - size = add_size(size, sizeof(pg_atomic_uint32)); // diskquota_shmem_size + size = add_size(size, sizeof(pg_atomic_uint64)); // diskquota_shmem_size #endif size = add_size(size, hash_estimate_size(MAX_DISK_QUOTA_REJECT_ENTRIES, @@ -607,7 +607,7 @@ init_disk_quota_model(uint32 id) initStringInfo(&str); #ifdef USE_ASSERT_CHECKING - Assert(pg_atomic_read_u32(diskquota_shmem_size) >= 0); + Assert(pg_atomic_read_u64(diskquota_shmem_size) >= 0); #endif format_name("TableSizeEntrymap", id, &str); @@ -618,7 +618,7 @@ init_disk_quota_model(uint32 id) &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, sizeof(TableSizeEntry))); #endif @@ -627,7 +627,7 @@ init_disk_quota_model(uint32 id) if (!found) *table_size_map_last_overflow_report = 0; #ifdef USE_ASSERT_CHECKING - if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, sizeof(TimestampTz)); + if (!found) pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(TimestampTz)); #endif /* for localrejectmap */ @@ -641,7 +641,7 @@ init_disk_quota_model(uint32 id) &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(diskquota_max_local_reject_entries, sizeof(LocalRejectMapEntry))); #endif @@ -650,7 +650,7 @@ init_disk_quota_model(uint32 id) if (!found) *local_disk_quota_reject_map_last_overflow_report = 0; #ifdef USE_ASSERT_CHECKING - if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, sizeof(TimestampTz)); + if (!found) pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(TimestampTz)); #endif /* for quota_info_map */ @@ -662,7 +662,7 @@ init_disk_quota_model(uint32 id) HASH_ELEM, DISKQUOTA_TAG_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, sizeof(QuotaInfoEntry))); + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, sizeof(QuotaInfoEntry))); #endif format_name("QuotaInfoMap_last_overflow_report", id, &str); @@ -670,13 +670,13 @@ init_disk_quota_model(uint32 id) if (!found) *quota_info_map_last_overflow_report = 0; #ifdef USE_ASSERT_CHECKING - if (!found) pg_atomic_sub_fetch_u32(diskquota_shmem_size, sizeof(TimestampTz)); + if (!found) pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(TimestampTz)); #endif pfree(str.data); #ifdef USE_ASSERT_CHECKING - Assert(pg_atomic_read_u32(diskquota_shmem_size) >= 0); + Assert(pg_atomic_read_u64(diskquota_shmem_size) >= 0); #endif } diff --git a/src/relation_cache.c b/src/relation_cache.c index d5e81b4f..2d489fc9 100644 --- a/src/relation_cache.c +++ b/src/relation_cache.c @@ -43,7 +43,7 @@ static const char *relid_cache_warning = "the GUC value for diskquota.max_active_tables."; #ifdef USE_ASSERT_CHECKING -extern pg_atomic_uint32 *diskquota_shmem_size; +extern pg_atomic_uint64 *diskquota_shmem_size; #endif static void update_relation_entry(Oid relid, DiskQuotaRelationCacheEntry *relation_entry, @@ -63,7 +63,7 @@ init_shm_worker_relation_cache(void) &ctl, HASH_ELEM, DISKQUOTA_OID_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelationCacheEntry))); #endif @@ -74,7 +74,7 @@ init_shm_worker_relation_cache(void) HASH_ELEM, DISKQUOTA_OID_HASH); #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u32(diskquota_shmem_size, + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelidCacheEntry))); #endif } From 3b4768f40036f77540d8d652e1a7119596e8c838 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 8 Dec 2025 21:29:46 +0500 Subject: [PATCH 10/41] simplify --- src/diskquota.c | 10 +-------- src/diskquota.h | 1 + src/diskquota_utility.c | 17 ++++++++++++++ src/gp_activetable.c | 13 ----------- src/quotamodel.c | 49 ++++------------------------------------- src/relation_cache.c | 14 ------------ 6 files changed, 23 insertions(+), 81 deletions(-) diff --git a/src/diskquota.c b/src/diskquota.c index 9fe1ad98..95d77930 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -105,10 +105,6 @@ static DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem; */ BackgroundWorkerHandle **bgworker_handles; -#ifdef USE_ASSERT_CHECKING -extern pg_atomic_uint64 *diskquota_shmem_size; -#endif - typedef enum { SUCCESS, @@ -1736,13 +1732,9 @@ void init_launcher_shmem() { bool found; - DiskquotaLauncherShmem = (DiskquotaLauncherShmemStruct *)ShmemInitStruct("Diskquota launcher Data", + DiskquotaLauncherShmem = (DiskquotaLauncherShmemStruct *)DiskquotaShmemInitStruct("Diskquota launcher Data", diskquota_launcher_shmem_size(), &found); -#ifdef USE_ASSERT_CHECKING - if (!found) pg_atomic_sub_fetch_u64(diskquota_shmem_size, diskquota_launcher_shmem_size()); -#endif - memset(DiskquotaLauncherShmem, 0, diskquota_launcher_shmem_size()); if (!found) { diff --git a/src/diskquota.h b/src/diskquota.h index c46adb21..b9c12dad 100644 --- a/src/diskquota.h +++ b/src/diskquota.h @@ -314,6 +314,7 @@ extern void diskquota_stop_worker(void); extern void update_monitordb_status(Oid dbid, uint32 status); extern HTAB *diskquota_hash_create(const char *tabname, long nelem, HASHCTL *info, int flags, DiskquotaHashFunction hashFunction); +extern void *DiskquotaShmemInitStruct(const char *name, Size size, bool *foundPtr); extern HTAB *DiskquotaShmemInitHash(const char *name, long init_size, long max_size, HASHCTL *infoP, int hash_flags, DiskquotaHashFunction hash_function); extern void refresh_monitored_dbid_cache(void); diff --git a/src/diskquota_utility.c b/src/diskquota_utility.c index 43d0b0a1..ac983d5a 100644 --- a/src/diskquota_utility.c +++ b/src/diskquota_utility.c @@ -114,6 +114,10 @@ static float4 get_per_segment_ratio(Oid spcoid); static bool to_delete_quota(QuotaType type, int64 quota_limit_mb, float4 segratio); static void check_role(Oid roleoid, char *rolname, int64 quota_limit_mb); +#ifdef USE_ASSERT_CHECKING +extern pg_atomic_uint64 *diskquota_shmem_size; +#endif + /* ---- Help Functions to set quota limit. ---- */ /* * Initialize table diskquota.table_size. @@ -1634,6 +1638,15 @@ diskquota_hash_create(const char *tabname, long nelem, HASHCTL *info, int flags, #endif /* GP_VERSION_NUM */ } +void * +DiskquotaShmemInitStruct(const char *name, Size size, bool *foundPtr) +{ +#ifdef USE_ASSERT_CHECKING + pg_atomic_sub_fetch_u64(diskquota_shmem_size, size); +#endif + return ShmemInitStruct(name, size, foundPtr); +} + HTAB * DiskquotaShmemInitHash(const char *name, /* table string name for shmem index */ long init_size, /* initial table size */ @@ -1642,6 +1655,10 @@ DiskquotaShmemInitHash(const char *name, /* table string name fo int hash_flags, /* info about infoP */ DiskquotaHashFunction hashFunction) { +#ifdef USE_ASSERT_CHECKING + pg_atomic_sub_fetch_u64(diskquota_shmem_size, + hash_estimate_size(max_size, infoP->entrysize)); +#endif #if GP_VERSION_NUM < 70000 if (hashFunction == DISKQUOTA_TAG_HASH) infoP->hash = tag_hash; diff --git a/src/gp_activetable.c b/src/gp_activetable.c index 4f34e1d6..bf34e2ae 100644 --- a/src/gp_activetable.c +++ b/src/gp_activetable.c @@ -79,10 +79,6 @@ static file_truncate_hook_type prev_file_truncate_hook = NULL; static file_unlink_hook_type prev_file_unlink_hook = NULL; static object_access_hook_type prev_object_access_hook = NULL; -#ifdef USE_ASSERT_CHECKING -extern pg_atomic_uint64 *diskquota_shmem_size; -#endif - static void active_table_hook_smgrcreate(RelFileNodeBackend rnode); static void active_table_hook_smgrextend(RelFileNodeBackend rnode); static void active_table_hook_smgrtruncate(RelFileNodeBackend rnode); @@ -118,20 +114,11 @@ init_shm_worker_active_tables(void) active_tables_map = DiskquotaShmemInitHash("active_tables", diskquota_max_active_tables, diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); -#ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u64(diskquota_shmem_size, - hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaActiveTableFileEntry))); -#endif - memset(&ctl, 0, sizeof(ctl)); ctl.keysize = sizeof(Oid); ctl.entrysize = sizeof(Oid); altered_reloid_cache = DiskquotaShmemInitHash("altered_reloid_cache", diskquota_max_active_tables, diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_OID_HASH); - -#ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(diskquota_max_active_tables, sizeof(Oid))); -#endif } /* diff --git a/src/quotamodel.c b/src/quotamodel.c index 00111ff9..b97ac9f0 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -460,13 +460,8 @@ disk_quota_shmem_startup(void) * to store out-of-quota rejectmap. active_tables_map is used to store * active tables whose disk usage is changed. */ - extension_ddl_message = ShmemInitStruct("disk_quota_extension_ddl_message", sizeof(ExtensionDDLMessage), &found); + extension_ddl_message = DiskquotaShmemInitStruct("disk_quota_extension_ddl_message", sizeof(ExtensionDDLMessage), &found); if (!found) memset((void *)extension_ddl_message, 0, sizeof(ExtensionDDLMessage)); - -#ifdef USE_ASSERT_CHECKING - if (!found) pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(ExtensionDDLMessage)); -#endif - memset(&hash_ctl, 0, sizeof(hash_ctl)); hash_ctl.keysize = sizeof(RejectMapEntry); hash_ctl.entrysize = sizeof(GlobalRejectMapEntry); @@ -474,11 +469,6 @@ disk_quota_shmem_startup(void) DiskquotaShmemInitHash("rejectmap whose quota limitation is reached", diskquota_max_local_reject_entries, MAX_DISK_QUOTA_REJECT_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); -#ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u64(diskquota_shmem_size, - hash_estimate_size(MAX_DISK_QUOTA_REJECT_ENTRIES, sizeof(GlobalRejectMapEntry))); -#endif - init_shm_worker_active_tables(); init_shm_worker_relation_cache(); @@ -491,11 +481,6 @@ disk_quota_shmem_startup(void) DiskquotaShmemInitHash("table oid cache which shoud tracking", diskquota_max_monitored_databases, diskquota_max_monitored_databases, &hash_ctl, HASH_ELEM, DISKQUOTA_OID_HASH); -#ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u64(diskquota_shmem_size, - hash_estimate_size(diskquota_max_monitored_databases, sizeof(struct MonitorDBEntryStruct))); -#endif - if (IS_QUERY_DISPATCHER()) init_launcher_shmem(); LWLockRelease(AddinShmemInitLock); @@ -617,19 +602,10 @@ init_disk_quota_model(uint32 id) table_size_map = DiskquotaShmemInitHash(str.data, INIT_NUM_TABLE_SIZE_ENTRIES, MAX_NUM_TABLE_SIZE_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); -#ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u64(diskquota_shmem_size, - hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, sizeof(TableSizeEntry))); -#endif - format_name("TableSizeEntrymap_last_overflow_report", id, &str); - table_size_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); + table_size_map_last_overflow_report = DiskquotaShmemInitStruct(str.data, sizeof(TimestampTz), &found); if (!found) *table_size_map_last_overflow_report = 0; -#ifdef USE_ASSERT_CHECKING - if (!found) pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(TimestampTz)); -#endif - /* for localrejectmap */ /* WARNNING: The max length of name of the map is 48 */ format_name("localrejectmap", id, &str); @@ -640,19 +616,10 @@ init_disk_quota_model(uint32 id) DiskquotaShmemInitHash(str.data, diskquota_max_local_reject_entries, diskquota_max_local_reject_entries, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); -#ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u64(diskquota_shmem_size, - hash_estimate_size(diskquota_max_local_reject_entries, sizeof(LocalRejectMapEntry))); -#endif - format_name("localrejectmap_last_overflow_report", id, &str); - local_disk_quota_reject_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); + local_disk_quota_reject_map_last_overflow_report = DiskquotaShmemInitStruct(str.data, sizeof(TimestampTz), &found); if (!found) *local_disk_quota_reject_map_last_overflow_report = 0; -#ifdef USE_ASSERT_CHECKING - if (!found) pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(TimestampTz)); -#endif - /* for quota_info_map */ format_name("QuotaInfoMap", id, &str); memset(&hash_ctl, 0, sizeof(hash_ctl)); @@ -661,18 +628,10 @@ init_disk_quota_model(uint32 id) quota_info_map = DiskquotaShmemInitHash(str.data, INIT_QUOTA_MAP_ENTRIES, MAX_QUOTA_MAP_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); -#ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, sizeof(QuotaInfoEntry))); -#endif - format_name("QuotaInfoMap_last_overflow_report", id, &str); - quota_info_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); + quota_info_map_last_overflow_report = DiskquotaShmemInitStruct(str.data, sizeof(TimestampTz), &found); if (!found) *quota_info_map_last_overflow_report = 0; -#ifdef USE_ASSERT_CHECKING - if (!found) pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(TimestampTz)); -#endif - pfree(str.data); #ifdef USE_ASSERT_CHECKING diff --git a/src/relation_cache.c b/src/relation_cache.c index 2d489fc9..b5624c42 100644 --- a/src/relation_cache.c +++ b/src/relation_cache.c @@ -42,10 +42,6 @@ static const char *relid_cache_warning = "the number of relid cache entries reached the limit, please increase " "the GUC value for diskquota.max_active_tables."; -#ifdef USE_ASSERT_CHECKING -extern pg_atomic_uint64 *diskquota_shmem_size; -#endif - static void update_relation_entry(Oid relid, DiskQuotaRelationCacheEntry *relation_entry, DiskQuotaRelidCacheEntry *relid_entry); @@ -62,21 +58,11 @@ init_shm_worker_relation_cache(void) relation_cache = DiskquotaShmemInitHash("relation_cache", diskquota_max_active_tables, diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_OID_HASH); -#ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u64(diskquota_shmem_size, - hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelationCacheEntry))); -#endif - memset(&ctl, 0, sizeof(ctl)); ctl.keysize = sizeof(Oid); ctl.entrysize = sizeof(DiskQuotaRelidCacheEntry); relid_cache = DiskquotaShmemInitHash("relid_cache", diskquota_max_active_tables, diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_OID_HASH); - -#ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u64(diskquota_shmem_size, - hash_estimate_size(diskquota_max_active_tables, sizeof(DiskQuotaRelidCacheEntry))); -#endif } Oid From fa0952b0719865a6af9ad79b8c3ee2b2954c5bf4 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 8 Dec 2025 21:30:15 +0500 Subject: [PATCH 11/41] format --- src/diskquota.c | 4 ++-- src/diskquota.h | 2 +- src/diskquota_utility.c | 3 +-- src/quotamodel.c | 3 ++- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/diskquota.c b/src/diskquota.c index 95d77930..b0e90d17 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -1732,8 +1732,8 @@ void init_launcher_shmem() { bool found; - DiskquotaLauncherShmem = (DiskquotaLauncherShmemStruct *)DiskquotaShmemInitStruct("Diskquota launcher Data", - diskquota_launcher_shmem_size(), &found); + DiskquotaLauncherShmem = (DiskquotaLauncherShmemStruct *)DiskquotaShmemInitStruct( + "Diskquota launcher Data", diskquota_launcher_shmem_size(), &found); memset(DiskquotaLauncherShmem, 0, diskquota_launcher_shmem_size()); if (!found) diff --git a/src/diskquota.h b/src/diskquota.h index b9c12dad..0bb4eb7c 100644 --- a/src/diskquota.h +++ b/src/diskquota.h @@ -314,7 +314,7 @@ extern void diskquota_stop_worker(void); extern void update_monitordb_status(Oid dbid, uint32 status); extern HTAB *diskquota_hash_create(const char *tabname, long nelem, HASHCTL *info, int flags, DiskquotaHashFunction hashFunction); -extern void *DiskquotaShmemInitStruct(const char *name, Size size, bool *foundPtr); +extern void *DiskquotaShmemInitStruct(const char *name, Size size, bool *foundPtr); extern HTAB *DiskquotaShmemInitHash(const char *name, long init_size, long max_size, HASHCTL *infoP, int hash_flags, DiskquotaHashFunction hash_function); extern void refresh_monitored_dbid_cache(void); diff --git a/src/diskquota_utility.c b/src/diskquota_utility.c index ac983d5a..1baa2406 100644 --- a/src/diskquota_utility.c +++ b/src/diskquota_utility.c @@ -1656,8 +1656,7 @@ DiskquotaShmemInitHash(const char *name, /* table string name fo DiskquotaHashFunction hashFunction) { #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u64(diskquota_shmem_size, - hash_estimate_size(max_size, infoP->entrysize)); + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(max_size, infoP->entrysize)); #endif #if GP_VERSION_NUM < 70000 if (hashFunction == DISKQUOTA_TAG_HASH) diff --git a/src/quotamodel.c b/src/quotamodel.c index b97ac9f0..e1842c61 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -460,7 +460,8 @@ disk_quota_shmem_startup(void) * to store out-of-quota rejectmap. active_tables_map is used to store * active tables whose disk usage is changed. */ - extension_ddl_message = DiskquotaShmemInitStruct("disk_quota_extension_ddl_message", sizeof(ExtensionDDLMessage), &found); + extension_ddl_message = + DiskquotaShmemInitStruct("disk_quota_extension_ddl_message", sizeof(ExtensionDDLMessage), &found); if (!found) memset((void *)extension_ddl_message, 0, sizeof(ExtensionDDLMessage)); memset(&hash_ctl, 0, sizeof(hash_ctl)); hash_ctl.keysize = sizeof(RejectMapEntry); From a79dfa6e7592b02675b62f4e81f7cf28dadd64b9 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 8 Dec 2025 21:55:25 +0500 Subject: [PATCH 12/41] simplify --- src/diskquota.c | 4 ++-- src/diskquota.h | 1 - src/diskquota_utility.c | 9 --------- src/quotamodel.c | 19 +++++++++++++------ 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/diskquota.c b/src/diskquota.c index b0e90d17..58b0fde4 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -1732,8 +1732,8 @@ void init_launcher_shmem() { bool found; - DiskquotaLauncherShmem = (DiskquotaLauncherShmemStruct *)DiskquotaShmemInitStruct( - "Diskquota launcher Data", diskquota_launcher_shmem_size(), &found); + DiskquotaLauncherShmem = (DiskquotaLauncherShmemStruct *)ShmemInitStruct("Diskquota launcher Data", + diskquota_launcher_shmem_size(), &found); memset(DiskquotaLauncherShmem, 0, diskquota_launcher_shmem_size()); if (!found) diff --git a/src/diskquota.h b/src/diskquota.h index 0bb4eb7c..c46adb21 100644 --- a/src/diskquota.h +++ b/src/diskquota.h @@ -314,7 +314,6 @@ extern void diskquota_stop_worker(void); extern void update_monitordb_status(Oid dbid, uint32 status); extern HTAB *diskquota_hash_create(const char *tabname, long nelem, HASHCTL *info, int flags, DiskquotaHashFunction hashFunction); -extern void *DiskquotaShmemInitStruct(const char *name, Size size, bool *foundPtr); extern HTAB *DiskquotaShmemInitHash(const char *name, long init_size, long max_size, HASHCTL *infoP, int hash_flags, DiskquotaHashFunction hash_function); extern void refresh_monitored_dbid_cache(void); diff --git a/src/diskquota_utility.c b/src/diskquota_utility.c index 1baa2406..086c358c 100644 --- a/src/diskquota_utility.c +++ b/src/diskquota_utility.c @@ -1638,15 +1638,6 @@ diskquota_hash_create(const char *tabname, long nelem, HASHCTL *info, int flags, #endif /* GP_VERSION_NUM */ } -void * -DiskquotaShmemInitStruct(const char *name, Size size, bool *foundPtr) -{ -#ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u64(diskquota_shmem_size, size); -#endif - return ShmemInitStruct(name, size, foundPtr); -} - HTAB * DiskquotaShmemInitHash(const char *name, /* table string name for shmem index */ long init_size, /* initial table size */ diff --git a/src/quotamodel.c b/src/quotamodel.c index e1842c61..c2a4f461 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -449,7 +449,15 @@ disk_quota_shmem_startup(void) #ifdef USE_ASSERT_CHECKING diskquota_shmem_size = ShmemInitStruct("diskquota_shmem_size", sizeof(pg_atomic_uint64), &found); - if (!found) pg_atomic_init_u64(diskquota_shmem_size, DiskQuotaShmemSize() - sizeof(pg_atomic_uint64)); + if (!found) + { + pg_atomic_init_u64(diskquota_shmem_size, DiskQuotaShmemSize()); + pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(pg_atomic_uint64)); // diskquota_shmem_size + pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(ExtensionDDLMessage)); // extension_ddl_message + + if (IS_QUERY_DISPATCHER()) + pg_atomic_sub_fetch_u64(diskquota_shmem_size, diskquota_launcher_shmem_size()); // DiskquotaLauncherShmem + } #endif init_lwlocks(); @@ -460,8 +468,7 @@ disk_quota_shmem_startup(void) * to store out-of-quota rejectmap. active_tables_map is used to store * active tables whose disk usage is changed. */ - extension_ddl_message = - DiskquotaShmemInitStruct("disk_quota_extension_ddl_message", sizeof(ExtensionDDLMessage), &found); + extension_ddl_message = ShmemInitStruct("disk_quota_extension_ddl_message", sizeof(ExtensionDDLMessage), &found); if (!found) memset((void *)extension_ddl_message, 0, sizeof(ExtensionDDLMessage)); memset(&hash_ctl, 0, sizeof(hash_ctl)); hash_ctl.keysize = sizeof(RejectMapEntry); @@ -604,7 +611,7 @@ init_disk_quota_model(uint32 id) &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); format_name("TableSizeEntrymap_last_overflow_report", id, &str); - table_size_map_last_overflow_report = DiskquotaShmemInitStruct(str.data, sizeof(TimestampTz), &found); + table_size_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); if (!found) *table_size_map_last_overflow_report = 0; /* for localrejectmap */ @@ -618,7 +625,7 @@ init_disk_quota_model(uint32 id) &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); format_name("localrejectmap_last_overflow_report", id, &str); - local_disk_quota_reject_map_last_overflow_report = DiskquotaShmemInitStruct(str.data, sizeof(TimestampTz), &found); + local_disk_quota_reject_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); if (!found) *local_disk_quota_reject_map_last_overflow_report = 0; /* for quota_info_map */ @@ -630,7 +637,7 @@ init_disk_quota_model(uint32 id) HASH_ELEM, DISKQUOTA_TAG_HASH); format_name("QuotaInfoMap_last_overflow_report", id, &str); - quota_info_map_last_overflow_report = DiskquotaShmemInitStruct(str.data, sizeof(TimestampTz), &found); + quota_info_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); if (!found) *quota_info_map_last_overflow_report = 0; pfree(str.data); From ceb42d32f1fa5e905bd3a58438d70b503b0b04a4 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 8 Dec 2025 21:57:23 +0500 Subject: [PATCH 13/41] revert --- src/diskquota.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/diskquota.c b/src/diskquota.c index 58b0fde4..aa706f40 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -1734,7 +1734,6 @@ init_launcher_shmem() bool found; DiskquotaLauncherShmem = (DiskquotaLauncherShmemStruct *)ShmemInitStruct("Diskquota launcher Data", diskquota_launcher_shmem_size(), &found); - memset(DiskquotaLauncherShmem, 0, diskquota_launcher_shmem_size()); if (!found) { From 99e41d60c3489d9c95ee18b8edbc04aff881d35d Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 8 Dec 2025 21:58:30 +0500 Subject: [PATCH 14/41] revet --- src/quotamodel.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index c2a4f461..4dd517e4 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -488,7 +488,6 @@ disk_quota_shmem_startup(void) monitored_dbid_cache = DiskquotaShmemInitHash("table oid cache which shoud tracking", diskquota_max_monitored_databases, diskquota_max_monitored_databases, &hash_ctl, HASH_ELEM, DISKQUOTA_OID_HASH); - if (IS_QUERY_DISPATCHER()) init_launcher_shmem(); LWLockRelease(AddinShmemInitLock); From dced14deea89058c65e650bd13863933f581c174 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 8 Dec 2025 21:59:44 +0500 Subject: [PATCH 15/41] revert --- src/quotamodel.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index 4dd517e4..128e8e76 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -608,7 +608,6 @@ init_disk_quota_model(uint32 id) hash_ctl.entrysize = sizeof(TableSizeEntry); table_size_map = DiskquotaShmemInitHash(str.data, INIT_NUM_TABLE_SIZE_ENTRIES, MAX_NUM_TABLE_SIZE_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); - format_name("TableSizeEntrymap_last_overflow_report", id, &str); table_size_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); if (!found) *table_size_map_last_overflow_report = 0; @@ -634,7 +633,6 @@ init_disk_quota_model(uint32 id) hash_ctl.keysize = sizeof(QuotaInfoEntryKey); quota_info_map = DiskquotaShmemInitHash(str.data, INIT_QUOTA_MAP_ENTRIES, MAX_QUOTA_MAP_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); - format_name("QuotaInfoMap_last_overflow_report", id, &str); quota_info_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); if (!found) *quota_info_map_last_overflow_report = 0; From 0b7c8297dafd830e081b96061ab1519b44299af2 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 8 Dec 2025 22:13:03 +0500 Subject: [PATCH 16/41] fix --- src/quotamodel.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/quotamodel.c b/src/quotamodel.c index 128e8e76..a0962001 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -612,6 +612,16 @@ init_disk_quota_model(uint32 id) table_size_map_last_overflow_report = ShmemInitStruct(str.data, sizeof(TimestampTz), &found); if (!found) *table_size_map_last_overflow_report = 0; +#ifdef USE_ASSERT_CHECKING + if (!found) + { + pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(TimestampTz)); // table_size_map_last_overflow_report + pg_atomic_sub_fetch_u64(diskquota_shmem_size, + sizeof(TimestampTz)); // local_disk_quota_reject_map_last_overflow_report + pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(TimestampTz)); // quota_info_map_last_overflow_report + } +#endif + /* for localrejectmap */ /* WARNNING: The max length of name of the map is 48 */ format_name("localrejectmap", id, &str); From 8f7531eac9ab703b48bf76f2774562e05b666011 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 8 Dec 2025 22:33:29 +0500 Subject: [PATCH 17/41] fix --- src/diskquota.c | 4 ++-- src/diskquota_utility.c | 5 ++++- src/quotamodel.c | 8 ++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/diskquota.c b/src/diskquota.c index aa706f40..c723005c 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -86,12 +86,12 @@ ExtensionDDLMessage *extension_ddl_message = NULL; // Only access in diskquota worker, different from each worker. // a pointer to DiskquotaLauncherShmem->workerEntries in shared memory -static DiskQuotaWorkerEntry *volatile MyWorkerInfo = NULL; +DiskQuotaWorkerEntry *volatile MyWorkerInfo = NULL; // how many database diskquota are monitoring on static int num_db = 0; -static DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem; +DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem = NULL; #define MIN_SLEEPTIME 100 /* milliseconds */ #define BGWORKER_LOG_TIME 3600000 /* milliseconds */ diff --git a/src/diskquota_utility.c b/src/diskquota_utility.c index 086c358c..a1f2c4e9 100644 --- a/src/diskquota_utility.c +++ b/src/diskquota_utility.c @@ -114,6 +114,8 @@ static float4 get_per_segment_ratio(Oid spcoid); static bool to_delete_quota(QuotaType type, int64 quota_limit_mb, float4 segratio); static void check_role(Oid roleoid, char *rolname, int64 quota_limit_mb); +extern DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem; + #ifdef USE_ASSERT_CHECKING extern pg_atomic_uint64 *diskquota_shmem_size; #endif @@ -1647,7 +1649,8 @@ DiskquotaShmemInitHash(const char *name, /* table string name fo DiskquotaHashFunction hashFunction) { #ifdef USE_ASSERT_CHECKING - pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(max_size, infoP->entrysize)); + if (!DiskquotaLauncherShmem || !DiskquotaLauncherShmem->isDynamicWorker) + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(max_size, infoP->entrysize)); #endif #if GP_VERSION_NUM < 70000 if (hashFunction == DISKQUOTA_TAG_HASH) diff --git a/src/quotamodel.c b/src/quotamodel.c index a0962001..e4264ccf 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -210,6 +210,8 @@ static const char *local_disk_quota_reject_map_warning = static shmem_startup_hook_type prev_shmem_startup_hook = NULL; +extern DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem; + #ifdef USE_ASSERT_CHECKING pg_atomic_uint64 *diskquota_shmem_size; #endif @@ -599,7 +601,9 @@ init_disk_quota_model(uint32 id) initStringInfo(&str); #ifdef USE_ASSERT_CHECKING - Assert(pg_atomic_read_u64(diskquota_shmem_size) >= 0); + Assert(DiskquotaLauncherShmem); + + if (!DiskquotaLauncherShmem->isDynamicWorker) Assert(pg_atomic_read_u64(diskquota_shmem_size) >= 0); #endif format_name("TableSizeEntrymap", id, &str); @@ -650,7 +654,7 @@ init_disk_quota_model(uint32 id) pfree(str.data); #ifdef USE_ASSERT_CHECKING - Assert(pg_atomic_read_u64(diskquota_shmem_size) >= 0); + if (!DiskquotaLauncherShmem->isDynamicWorker) Assert(pg_atomic_read_u64(diskquota_shmem_size) >= 0); #endif } From 79ef88e2095058976dba5d516806178fa87fde46 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 9 Dec 2025 10:32:07 +0500 Subject: [PATCH 18/41] revert --- src/diskquota.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diskquota.c b/src/diskquota.c index c723005c..104eab38 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -86,7 +86,7 @@ ExtensionDDLMessage *extension_ddl_message = NULL; // Only access in diskquota worker, different from each worker. // a pointer to DiskquotaLauncherShmem->workerEntries in shared memory -DiskQuotaWorkerEntry *volatile MyWorkerInfo = NULL; +static DiskQuotaWorkerEntry *volatile MyWorkerInfo = NULL; // how many database diskquota are monitoring on static int num_db = 0; From 994c9f19e35da0784ebf2815ca8372fa70739fbe Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 9 Dec 2025 10:33:39 +0500 Subject: [PATCH 19/41] revert --- src/quotamodel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/quotamodel.c b/src/quotamodel.c index e4264ccf..61296c3a 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -472,6 +472,7 @@ disk_quota_shmem_startup(void) */ extension_ddl_message = ShmemInitStruct("disk_quota_extension_ddl_message", sizeof(ExtensionDDLMessage), &found); if (!found) memset((void *)extension_ddl_message, 0, sizeof(ExtensionDDLMessage)); + memset(&hash_ctl, 0, sizeof(hash_ctl)); hash_ctl.keysize = sizeof(RejectMapEntry); hash_ctl.entrysize = sizeof(GlobalRejectMapEntry); From 5ab2417f578a4256269151a707c4d16fa0f22c68 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 10 Dec 2025 12:25:11 +0500 Subject: [PATCH 20/41] updates --- src/diskquota.c | 3 --- src/quotamodel.c | 21 +++++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/diskquota.c b/src/diskquota.c index 0d863374..ae09716f 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -96,9 +96,6 @@ DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem = NULL; /* how many TableSizeEntry are maintained in all the table_size_map in shared memory */ pg_atomic_uint32 *diskquota_table_size_entry_num; -/* how many LocalRejectMapEntry are maintained in all the local_disk_quota_reject_map in shared memory */ -pg_atomic_uint32 *diskquota_local_disk_quota_reject_entry_num; - /* how many QuotaInfoEntry are maintained in all the quota_info_map in shared memory */ pg_atomic_uint32 *diskquota_quota_info_entry_num; diff --git a/src/quotamodel.c b/src/quotamodel.c index e8a450f0..f2c8130e 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -462,7 +462,15 @@ disk_quota_shmem_startup(void) pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(ExtensionDDLMessage)); // extension_ddl_message if (IS_QUERY_DISPATCHER()) + { pg_atomic_sub_fetch_u64(diskquota_shmem_size, diskquota_launcher_shmem_size()); // DiskquotaLauncherShmem + pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(pg_atomic_uint32)); // diskquota_table_size_entry_num + pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(pg_atomic_uint32)); // diskquota_quota_info_entry_num + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, + sizeof(TableSizeEntry))); // table_size_map + pg_atomic_sub_fetch_u64(diskquota_shmem_size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, + sizeof(QuotaInfoEntry))); // quota_info_map + } } #endif @@ -548,11 +556,11 @@ static Size diskquota_worker_shmem_size(void) { Size size; - size = hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, sizeof(TableSizeEntry)); // table_size_map + size = hash_estimate_size(0, 0); // table_size_map size = add_size(size, hash_estimate_size(diskquota_max_local_reject_entries, sizeof(LocalRejectMapEntry))); // local_disk_quota_reject_map - size = add_size(size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, sizeof(QuotaInfoEntry))); // quota_info_map - size = add_size(size, sizeof(TimestampTz)); // table_size_map_last_overflow_report + size = add_size(size, hash_estimate_size(0, 0)); // quota_info_map + size = add_size(size, sizeof(TimestampTz)); // table_size_map_last_overflow_report size = add_size(size, sizeof(TimestampTz)); // local_disk_quota_reject_map_last_overflow_report size = add_size(size, sizeof(TimestampTz)); // quota_info_map_last_overflow_report return size; @@ -587,9 +595,10 @@ DiskQuotaShmemSize(void) if (IS_QUERY_DISPATCHER()) { size = add_size(size, diskquota_launcher_shmem_size()); // DiskquotaLauncherShmem - size = add_size(size, sizeof(pg_atomic_uint32)); // diskquota_table_size_entry_num - size = add_size(size, sizeof(pg_atomic_uint32)); // diskquota_local_disk_quota_reject_entry_num - size = add_size(size, sizeof(pg_atomic_uint32)); // diskquota_quota_info_entry_num + size = add_size(size, sizeof(pg_atomic_uint32)); // diskquota_table_size_entry_num + size = add_size(size, sizeof(pg_atomic_uint32)); // diskquota_quota_info_entry_num + size = add_size(size, hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, sizeof(TableSizeEntry))); // table_size_map + size = add_size(size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, sizeof(QuotaInfoEntry))); // quota_info_map size = add_size(size, diskquota_worker_shmem_size() * diskquota_max_monitored_databases); } From ce9fc989836fa01fcf70ac8a0525aa9a63dbfff7 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 10 Dec 2025 13:38:35 +0500 Subject: [PATCH 21/41] fix --- src/diskquota_utility.c | 6 +- src/quotamodel.c | 3 + .../expected/test_many_active_tables.out | 508 +++++++++++++++++- tests/regress/sql/test_many_active_tables.sql | 8 +- 4 files changed, 512 insertions(+), 13 deletions(-) diff --git a/src/diskquota_utility.c b/src/diskquota_utility.c index d614dda5..79925579 100644 --- a/src/diskquota_utility.c +++ b/src/diskquota_utility.c @@ -1697,11 +1697,7 @@ check_hash_fullness_num(HTAB *hashp, pg_atomic_uint32 *counter, int max_size, co { uint32 num_entries = pg_atomic_read_u32(counter); - if (num_entries < max_size) - { - (void)pg_atomic_add_fetch_u32(counter, 1); - return HASH_ENTER; - } + if (num_entries < max_size) return HASH_ENTER; if (num_entries == max_size) { diff --git a/src/quotamodel.c b/src/quotamodel.c index f2c8130e..bdd83ed0 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -284,6 +284,7 @@ update_size_for_quota(int64 size, QuotaType type, Oid *keys, int16 segid) { entry->size = 0; entry->limit = -1; + pg_atomic_add_fetch_u32(diskquota_quota_info_entry_num, 1); } entry->size += size; } @@ -310,6 +311,7 @@ update_limit_for_quota(int64 limit, float segratio, QuotaType type, Oid *keys) if (!found) { entry->size = 0; + pg_atomic_add_fetch_u32(diskquota_quota_info_entry_num, 1); } if (key.segid == -1) entry->limit = limit; @@ -995,6 +997,7 @@ get_table_size_map_entry(Oid oid, int16 segid) int seg_st = TableSizeEntrySegidStart(tsentry); int seg_ed = TableSizeEntrySegidEnd(tsentry); for (int j = seg_st; j < seg_ed; j++) TableSizeEntrySetFlushFlag(tsentry, j); + pg_atomic_add_fetch_u32(diskquota_table_size_entry_num, 1); } return tsentry; diff --git a/tests/regress/expected/test_many_active_tables.out b/tests/regress/expected/test_many_active_tables.out index 09f87c8a..8bf81587 100644 --- a/tests/regress/expected/test_many_active_tables.out +++ b/tests/regress/expected/test_many_active_tables.out @@ -1,6 +1,6 @@ CREATE TABLE t1 (pk int, val int) DISTRIBUTED BY (pk) -PARTITION BY RANGE (pk) (START (1) END (500) EVERY (1)); +PARTITION BY RANGE (pk) (START (1) END (1000) EVERY (1)); NOTICE: CREATE TABLE will create partition "t1_1_prt_1" for table "t1" NOTICE: CREATE TABLE will create partition "t1_1_prt_2" for table "t1" NOTICE: CREATE TABLE will create partition "t1_1_prt_3" for table "t1" @@ -500,16 +500,516 @@ NOTICE: CREATE TABLE will create partition "t1_1_prt_496" for table "t1" NOTICE: CREATE TABLE will create partition "t1_1_prt_497" for table "t1" NOTICE: CREATE TABLE will create partition "t1_1_prt_498" for table "t1" NOTICE: CREATE TABLE will create partition "t1_1_prt_499" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_500" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_501" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_502" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_503" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_504" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_505" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_506" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_507" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_508" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_509" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_510" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_511" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_512" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_513" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_514" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_515" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_516" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_517" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_518" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_519" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_520" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_521" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_522" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_523" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_524" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_525" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_526" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_527" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_528" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_529" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_530" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_531" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_532" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_533" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_534" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_535" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_536" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_537" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_538" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_539" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_540" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_541" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_542" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_543" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_544" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_545" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_546" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_547" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_548" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_549" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_550" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_551" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_552" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_553" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_554" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_555" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_556" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_557" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_558" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_559" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_560" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_561" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_562" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_563" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_564" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_565" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_566" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_567" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_568" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_569" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_570" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_571" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_572" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_573" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_574" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_575" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_576" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_577" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_578" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_579" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_580" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_581" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_582" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_583" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_584" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_585" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_586" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_587" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_588" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_589" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_590" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_591" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_592" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_593" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_594" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_595" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_596" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_597" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_598" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_599" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_600" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_601" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_602" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_603" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_604" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_605" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_606" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_607" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_608" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_609" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_610" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_611" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_612" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_613" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_614" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_615" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_616" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_617" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_618" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_619" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_620" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_621" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_622" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_623" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_624" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_625" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_626" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_627" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_628" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_629" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_630" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_631" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_632" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_633" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_634" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_635" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_636" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_637" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_638" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_639" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_640" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_641" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_642" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_643" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_644" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_645" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_646" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_647" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_648" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_649" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_650" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_651" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_652" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_653" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_654" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_655" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_656" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_657" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_658" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_659" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_660" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_661" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_662" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_663" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_664" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_665" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_666" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_667" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_668" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_669" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_670" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_671" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_672" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_673" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_674" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_675" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_676" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_677" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_678" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_679" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_680" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_681" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_682" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_683" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_684" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_685" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_686" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_687" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_688" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_689" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_690" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_691" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_692" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_693" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_694" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_695" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_696" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_697" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_698" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_699" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_700" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_701" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_702" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_703" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_704" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_705" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_706" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_707" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_708" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_709" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_710" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_711" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_712" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_713" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_714" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_715" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_716" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_717" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_718" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_719" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_720" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_721" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_722" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_723" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_724" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_725" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_726" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_727" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_728" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_729" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_730" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_731" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_732" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_733" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_734" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_735" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_736" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_737" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_738" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_739" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_740" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_741" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_742" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_743" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_744" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_745" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_746" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_747" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_748" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_749" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_750" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_751" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_752" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_753" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_754" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_755" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_756" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_757" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_758" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_759" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_760" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_761" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_762" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_763" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_764" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_765" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_766" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_767" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_768" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_769" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_770" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_771" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_772" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_773" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_774" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_775" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_776" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_777" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_778" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_779" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_780" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_781" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_782" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_783" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_784" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_785" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_786" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_787" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_788" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_789" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_790" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_791" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_792" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_793" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_794" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_795" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_796" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_797" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_798" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_799" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_800" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_801" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_802" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_803" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_804" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_805" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_806" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_807" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_808" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_809" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_810" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_811" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_812" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_813" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_814" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_815" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_816" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_817" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_818" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_819" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_820" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_821" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_822" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_823" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_824" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_825" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_826" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_827" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_828" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_829" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_830" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_831" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_832" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_833" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_834" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_835" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_836" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_837" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_838" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_839" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_840" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_841" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_842" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_843" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_844" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_845" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_846" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_847" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_848" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_849" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_850" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_851" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_852" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_853" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_854" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_855" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_856" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_857" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_858" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_859" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_860" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_861" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_862" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_863" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_864" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_865" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_866" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_867" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_868" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_869" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_870" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_871" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_872" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_873" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_874" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_875" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_876" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_877" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_878" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_879" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_880" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_881" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_882" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_883" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_884" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_885" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_886" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_887" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_888" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_889" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_890" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_891" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_892" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_893" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_894" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_895" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_896" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_897" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_898" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_899" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_900" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_901" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_902" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_903" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_904" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_905" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_906" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_907" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_908" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_909" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_910" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_911" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_912" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_913" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_914" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_915" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_916" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_917" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_918" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_919" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_920" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_921" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_922" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_923" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_924" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_925" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_926" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_927" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_928" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_929" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_930" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_931" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_932" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_933" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_934" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_935" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_936" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_937" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_938" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_939" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_940" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_941" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_942" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_943" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_944" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_945" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_946" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_947" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_948" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_949" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_950" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_951" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_952" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_953" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_954" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_955" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_956" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_957" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_958" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_959" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_960" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_961" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_962" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_963" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_964" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_965" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_966" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_967" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_968" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_969" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_970" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_971" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_972" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_973" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_974" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_975" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_976" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_977" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_978" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_979" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_980" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_981" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_982" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_983" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_984" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_985" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_986" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_987" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_988" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_989" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_990" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_991" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_992" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_993" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_994" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_995" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_996" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_997" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_998" for table "t1" +NOTICE: CREATE TABLE will create partition "t1_1_prt_999" for table "t1" INSERT INTO t1 SELECT pk, val -FROM generate_series(1, 10000) AS val, generate_series(1, 499) AS pk; +FROM generate_series(1, 10000) AS val, generate_series(1, 999) AS pk; SELECT diskquota.wait_for_worker_new_epoch(); wait_for_worker_new_epoch --------------------------- t (1 row) -SELECT count(*) >= 499 FROM diskquota.table_size WHERE size > 0; +SELECT count(*) >= 999 FROM diskquota.table_size WHERE size > 0; ?column? ---------- t @@ -522,7 +1022,7 @@ SELECT diskquota.wait_for_worker_new_epoch(); t (1 row) -SELECT count(*) < 499 FROM diskquota.table_size WHERE size > 0; +SELECT count(*) < 999 FROM diskquota.table_size WHERE size > 0; ?column? ---------- t diff --git a/tests/regress/sql/test_many_active_tables.sql b/tests/regress/sql/test_many_active_tables.sql index 7531725b..4c617cf6 100644 --- a/tests/regress/sql/test_many_active_tables.sql +++ b/tests/regress/sql/test_many_active_tables.sql @@ -1,17 +1,17 @@ CREATE TABLE t1 (pk int, val int) DISTRIBUTED BY (pk) -PARTITION BY RANGE (pk) (START (1) END (500) EVERY (1)); +PARTITION BY RANGE (pk) (START (1) END (1000) EVERY (1)); INSERT INTO t1 SELECT pk, val -FROM generate_series(1, 10000) AS val, generate_series(1, 499) AS pk; +FROM generate_series(1, 10000) AS val, generate_series(1, 999) AS pk; SELECT diskquota.wait_for_worker_new_epoch(); -SELECT count(*) >= 499 FROM diskquota.table_size WHERE size > 0; +SELECT count(*) >= 999 FROM diskquota.table_size WHERE size > 0; DROP TABLE t1; SELECT diskquota.wait_for_worker_new_epoch(); -SELECT count(*) < 499 FROM diskquota.table_size WHERE size > 0; +SELECT count(*) < 999 FROM diskquota.table_size WHERE size > 0; From 42b448248d683783ab2d325510eaedf8bc2d5a24 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 10 Dec 2025 13:42:56 +0500 Subject: [PATCH 22/41] optimize --- src/diskquota.h | 4 ++-- src/diskquota_utility.c | 34 ++++++++-------------------------- src/quotamodel.c | 6 +++--- 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/src/diskquota.h b/src/diskquota.h index 921a5cdc..c68307d1 100644 --- a/src/diskquota.h +++ b/src/diskquota.h @@ -317,10 +317,10 @@ extern HTAB *diskquota_hash_create(const char *tabname, long nelem, HASHC extern HTAB *DiskquotaShmemInitHash(const char *name, long init_size, long max_size, HASHCTL *infoP, int hash_flags, DiskquotaHashFunction hash_function); extern void refresh_monitored_dbid_cache(void); +extern HASHACTION check_hash_fullness_num(HTAB *hashp, int num_entries, int max_size, + const char *warning_message, TimestampTz *last_overflow_report); extern HASHACTION check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message, TimestampTz *last_overflow_report); -extern HASHACTION check_hash_fullness_num(HTAB *hashp, pg_atomic_uint32 *counter, int max_size, - const char *warning_message, TimestampTz *last_overflow_report); bool SPI_push_cond_and_connect(void); void SPI_finish_and_pop_cond(bool pushed); #endif diff --git a/src/diskquota_utility.c b/src/diskquota_utility.c index 79925579..61f27dac 100644 --- a/src/diskquota_utility.c +++ b/src/diskquota_utility.c @@ -1665,15 +1665,10 @@ DiskquotaShmemInitHash(const char *name, /* table string name fo #endif /* GP_VERSION_NUM */ } -/* - * Returns HASH_FIND if hash table is full and HASH_ENTER otherwise. - * It can be used only under lock. - */ HASHACTION -check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message, TimestampTz *last_overflow_report) +check_hash_fullness_num(HTAB *hashp, int num_entries, int max_size, const char *warning_message, + TimestampTz *last_overflow_report) { - long num_entries = hash_get_num_entries(hashp); - if (num_entries < max_size) return HASH_ENTER; if (num_entries == max_size) @@ -1691,27 +1686,14 @@ check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message, Time return HASH_FIND; } +/* + * Returns HASH_FIND if hash table is full and HASH_ENTER otherwise. + * It can be used only under lock. + */ HASHACTION -check_hash_fullness_num(HTAB *hashp, pg_atomic_uint32 *counter, int max_size, const char *warning_message, - TimestampTz *last_overflow_report) +check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message, TimestampTz *last_overflow_report) { - uint32 num_entries = pg_atomic_read_u32(counter); - - if (num_entries < max_size) return HASH_ENTER; - - if (num_entries == max_size) - { - TimestampTz current_time = GetCurrentTimestamp(); - - if (*last_overflow_report == 0 || TimestampDifferenceExceeds(*last_overflow_report, current_time, - diskquota_hashmap_overflow_report_timeout * 1000)) - { - ereport(WARNING, (errmsg("[diskquota] %s", warning_message))); - *last_overflow_report = current_time; - } - } - - return HASH_FIND; + return check_hash_fullness_num(hashp, hash_get_num_entries(hashp), max_size, warning_message, last_overflow_report); } bool diff --git a/src/quotamodel.c b/src/quotamodel.c index bdd83ed0..2e034030 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -275,7 +275,7 @@ update_size_for_quota(int64 size, QuotaType type, Oid *keys, int16 segid) memcpy(key.keys, keys, quota_key_num[type] * sizeof(Oid)); key.type = type; key.segid = segid; - action = check_hash_fullness_num(quota_info_map, diskquota_quota_info_entry_num, diskquota_max_quota_probes, + action = check_hash_fullness_num(quota_info_map, pg_atomic_read_u32(diskquota_quota_info_entry_num), diskquota_max_quota_probes, quota_info_map_warning, quota_info_map_last_overflow_report); entry = hash_search(quota_info_map, &key, action, &found); /* If the number of quota exceeds the limit, entry will be NULL */ @@ -303,7 +303,7 @@ update_limit_for_quota(int64 limit, float segratio, QuotaType type, Oid *keys) memcpy(key.keys, keys, quota_key_num[type] * sizeof(Oid)); key.type = type; key.segid = i; - action = check_hash_fullness_num(quota_info_map, diskquota_quota_info_entry_num, diskquota_max_quota_probes, + action = check_hash_fullness_num(quota_info_map, pg_atomic_read_u32(diskquota_quota_info_entry_num), diskquota_max_quota_probes, quota_info_map_warning, quota_info_map_last_overflow_report); entry = hash_search(quota_info_map, &key, action, &found); /* If the number of quota exceeds the limit, entry will be NULL */ @@ -982,7 +982,7 @@ get_table_size_map_entry(Oid oid, int16 segid) bool found; TableSizeEntryKey key = {.reloid = oid, .id = TableSizeEntryId(segid)}; HASHACTION action = - check_hash_fullness_num(table_size_map, diskquota_table_size_entry_num, MAX_NUM_TABLE_SIZE_ENTRIES, + check_hash_fullness_num(table_size_map, pg_atomic_read_u32(diskquota_table_size_entry_num), MAX_NUM_TABLE_SIZE_ENTRIES, table_size_map_warning, table_size_map_last_overflow_report); TableSizeEntry *tsentry = hash_search(table_size_map, &key, action, &found); From f84badc1c1803259161094ed076530f7a2261701 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 10 Dec 2025 13:43:43 +0500 Subject: [PATCH 23/41] format --- src/diskquota.h | 4 ++-- src/quotamodel.c | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/diskquota.h b/src/diskquota.h index c68307d1..4458dc92 100644 --- a/src/diskquota.h +++ b/src/diskquota.h @@ -317,8 +317,8 @@ extern HTAB *diskquota_hash_create(const char *tabname, long nelem, HASHC extern HTAB *DiskquotaShmemInitHash(const char *name, long init_size, long max_size, HASHCTL *infoP, int hash_flags, DiskquotaHashFunction hash_function); extern void refresh_monitored_dbid_cache(void); -extern HASHACTION check_hash_fullness_num(HTAB *hashp, int num_entries, int max_size, - const char *warning_message, TimestampTz *last_overflow_report); +extern HASHACTION check_hash_fullness_num(HTAB *hashp, int num_entries, int max_size, const char *warning_message, + TimestampTz *last_overflow_report); extern HASHACTION check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message, TimestampTz *last_overflow_report); bool SPI_push_cond_and_connect(void); diff --git a/src/quotamodel.c b/src/quotamodel.c index 2e034030..ff1733ae 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -275,8 +275,9 @@ update_size_for_quota(int64 size, QuotaType type, Oid *keys, int16 segid) memcpy(key.keys, keys, quota_key_num[type] * sizeof(Oid)); key.type = type; key.segid = segid; - action = check_hash_fullness_num(quota_info_map, pg_atomic_read_u32(diskquota_quota_info_entry_num), diskquota_max_quota_probes, - quota_info_map_warning, quota_info_map_last_overflow_report); + action = check_hash_fullness_num(quota_info_map, pg_atomic_read_u32(diskquota_quota_info_entry_num), + diskquota_max_quota_probes, quota_info_map_warning, + quota_info_map_last_overflow_report); entry = hash_search(quota_info_map, &key, action, &found); /* If the number of quota exceeds the limit, entry will be NULL */ if (entry == NULL) return; @@ -303,8 +304,9 @@ update_limit_for_quota(int64 limit, float segratio, QuotaType type, Oid *keys) memcpy(key.keys, keys, quota_key_num[type] * sizeof(Oid)); key.type = type; key.segid = i; - action = check_hash_fullness_num(quota_info_map, pg_atomic_read_u32(diskquota_quota_info_entry_num), diskquota_max_quota_probes, - quota_info_map_warning, quota_info_map_last_overflow_report); + action = check_hash_fullness_num(quota_info_map, pg_atomic_read_u32(diskquota_quota_info_entry_num), + diskquota_max_quota_probes, quota_info_map_warning, + quota_info_map_last_overflow_report); entry = hash_search(quota_info_map, &key, action, &found); /* If the number of quota exceeds the limit, entry will be NULL */ if (entry == NULL) continue; @@ -980,10 +982,10 @@ static TableSizeEntry * get_table_size_map_entry(Oid oid, int16 segid) { bool found; - TableSizeEntryKey key = {.reloid = oid, .id = TableSizeEntryId(segid)}; - HASHACTION action = - check_hash_fullness_num(table_size_map, pg_atomic_read_u32(diskquota_table_size_entry_num), MAX_NUM_TABLE_SIZE_ENTRIES, - table_size_map_warning, table_size_map_last_overflow_report); + TableSizeEntryKey key = {.reloid = oid, .id = TableSizeEntryId(segid)}; + HASHACTION action = check_hash_fullness_num(table_size_map, pg_atomic_read_u32(diskquota_table_size_entry_num), + MAX_NUM_TABLE_SIZE_ENTRIES, table_size_map_warning, + table_size_map_last_overflow_report); TableSizeEntry *tsentry = hash_search(table_size_map, &key, action, &found); if (!found && tsentry != NULL) From a324cbe40f1b64cb3f88a57fb18ecc70994b8426 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 11 Dec 2025 08:40:17 +0500 Subject: [PATCH 24/41] fix --- src/quotamodel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index ff1733ae..5d176a1c 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -560,11 +560,11 @@ static Size diskquota_worker_shmem_size(void) { Size size; - size = hash_estimate_size(0, 0); // table_size_map + size = hash_estimate_size(INIT_NUM_TABLE_SIZE_ENTRIES, sizeof(TableSizeEntry)); // table_size_map size = add_size(size, hash_estimate_size(diskquota_max_local_reject_entries, sizeof(LocalRejectMapEntry))); // local_disk_quota_reject_map - size = add_size(size, hash_estimate_size(0, 0)); // quota_info_map - size = add_size(size, sizeof(TimestampTz)); // table_size_map_last_overflow_report + size = add_size(size, hash_estimate_size(INIT_QUOTA_MAP_ENTRIES, sizeof(QuotaInfoEntry))); // quota_info_map + size = add_size(size, sizeof(TimestampTz)); // table_size_map_last_overflow_report size = add_size(size, sizeof(TimestampTz)); // local_disk_quota_reject_map_last_overflow_report size = add_size(size, sizeof(TimestampTz)); // quota_info_map_last_overflow_report return size; From 30648621b228d20caae6571cefa27029aa3b1da4 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 11 Dec 2025 08:55:30 +0500 Subject: [PATCH 25/41] fix --- src/diskquota.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/diskquota.h b/src/diskquota.h index 4458dc92..1bba3136 100644 --- a/src/diskquota.h +++ b/src/diskquota.h @@ -42,9 +42,10 @@ #define MAX_NUM_KEYS_QUOTA_MAP 8 /* init number of QuotaInfoEntry in quota_info_map */ #define INIT_QUOTA_MAP_ENTRIES 128 -#define AVG_QUOTA_MAP_ENTRIES (diskquota_max_quota_probes / diskquota_max_monitored_databases) /* max number of QuotaInfoEntry in quota_info_map */ -#define MAX_QUOTA_MAP_ENTRIES (AVG_QUOTA_MAP_ENTRIES < 1024 ? 1024 : AVG_QUOTA_MAP_ENTRIES) +#define MAX_QUOTA_MAP_ENTRIES \ + (diskquota_max_quota_probes < 1024 * diskquota_max_monitored_databases ? 1024 * diskquota_max_monitored_databases \ + : diskquota_max_quota_probes) typedef enum { From fd56b9b6fef7179158d2e9c28bcb48880b22f748 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 11 Dec 2025 09:01:43 +0500 Subject: [PATCH 26/41] fix --- src/quotamodel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index 5d176a1c..fedf4654 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -275,10 +275,10 @@ update_size_for_quota(int64 size, QuotaType type, Oid *keys, int16 segid) memcpy(key.keys, keys, quota_key_num[type] * sizeof(Oid)); key.type = type; key.segid = segid; - action = check_hash_fullness_num(quota_info_map, pg_atomic_read_u32(diskquota_quota_info_entry_num), - diskquota_max_quota_probes, quota_info_map_warning, - quota_info_map_last_overflow_report); - entry = hash_search(quota_info_map, &key, action, &found); + action = + check_hash_fullness_num(quota_info_map, pg_atomic_read_u32(diskquota_quota_info_entry_num), + MAX_QUOTA_MAP_ENTRIES, quota_info_map_warning, quota_info_map_last_overflow_report); + entry = hash_search(quota_info_map, &key, action, &found); /* If the number of quota exceeds the limit, entry will be NULL */ if (entry == NULL) return; if (!found) @@ -305,7 +305,7 @@ update_limit_for_quota(int64 limit, float segratio, QuotaType type, Oid *keys) key.type = type; key.segid = i; action = check_hash_fullness_num(quota_info_map, pg_atomic_read_u32(diskquota_quota_info_entry_num), - diskquota_max_quota_probes, quota_info_map_warning, + MAX_QUOTA_MAP_ENTRIES, quota_info_map_warning, quota_info_map_last_overflow_report); entry = hash_search(quota_info_map, &key, action, &found); /* If the number of quota exceeds the limit, entry will be NULL */ From 83143a80e1e3e555663e638544b82c6eed603ffe Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 16 Dec 2025 12:40:44 +0500 Subject: [PATCH 27/41] fix --- src/diskquota.c | 4 ++-- src/diskquota.h | 2 ++ src/quotamodel.c | 22 +++++++++------------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/diskquota.c b/src/diskquota.c index 388bcde0..1a0a880f 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -1780,12 +1780,12 @@ init_launcher_shmem() } /* init TableSizeEntry counter */ diskquota_table_size_entry_num = - ShmemInitStruct("diskquota TableSizeEntry counter", sizeof(pg_atomic_uint32), &found); + DiskquotaShmemInitStruct("diskquota TableSizeEntry counter", DISKQUOTA_TABLE_SIZE_ENTRY_NUM_SIZE, &found); if (!found) pg_atomic_init_u32(diskquota_table_size_entry_num, 0); /* init QuotaInfoEntry counter */ diskquota_quota_info_entry_num = - ShmemInitStruct("diskquota QuotaInfoEntry counter", sizeof(pg_atomic_uint32), &found); + DiskquotaShmemInitStruct("diskquota QuotaInfoEntry counter", DISKQUOTA_QUOTA_INFO_ENTRY_NUM_SIZE, &found); if (!found) pg_atomic_init_u32(diskquota_quota_info_entry_num, 0); } diff --git a/src/diskquota.h b/src/diskquota.h index 7c0f06ee..cff3a482 100644 --- a/src/diskquota.h +++ b/src/diskquota.h @@ -82,6 +82,8 @@ extern int diskquota_worker_timeout; #define RELID_CACHE_ENTRY_SIZE sizeof(DiskQuotaRelidCacheEntry) #define ALTERED_RELOID_CACHE_ENTRY_SIZE sizeof(Oid) #define MONITORED_DBID_CACHE_ENTRY_SIZE sizeof(struct MonitorDBEntryStruct) +#define DISKQUOTA_TABLE_SIZE_ENTRY_NUM_SIZE sizeof(pg_atomic_uint32) +#define DISKQUOTA_QUOTA_INFO_ENTRY_NUM_SIZE sizeof(pg_atomic_uint32) typedef enum { diff --git a/src/quotamodel.c b/src/quotamodel.c index 0916751c..b1892b48 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -509,7 +509,9 @@ disk_quota_shmem_startup(void) #ifdef USE_ASSERT_CHECKING if (IS_QUERY_DISPATCHER()) Assert(pg_atomic_read_u64(diskquota_shmem_size) == - diskquota_worker_shmem_size() * diskquota_max_monitored_databases); + diskquota_worker_shmem_size() * diskquota_max_monitored_databases + + hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, TABLE_SIZE_MAP_ENTRY_SIZE) + + hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, QUOTA_INFO_MAP_ENTRY_SIZE)); else Assert(pg_atomic_read_u64(diskquota_shmem_size) == 0); #endif @@ -556,10 +558,10 @@ static Size diskquota_worker_shmem_size(void) { Size size; - size = hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, TABLE_SIZE_MAP_ENTRY_SIZE); + size = hash_estimate_size(INIT_NUM_TABLE_SIZE_ENTRIES, TABLE_SIZE_MAP_ENTRY_SIZE); size = add_size(size, hash_estimate_size(diskquota_max_local_reject_entries, LOCAL_DISK_QUOTA_REJECT_MAP_ENTRY_SIZE)); - size = add_size(size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, QUOTA_INFO_MAP_ENTRY_SIZE)); + size = add_size(size, hash_estimate_size(INIT_QUOTA_MAP_ENTRIES, QUOTA_INFO_MAP_ENTRY_SIZE)); size = add_size(size, TABLE_SIZE_MAP_LAST_OVERFLOW_REPORT_SIZE); size = add_size(size, LOCAL_DISK_QUOTA_REJECT_MAP_LAST_OVERFLOW_REPORT_SIZE); size = add_size(size, QUOTA_INFO_MAP_LAST_OVERFLOW_REPORT_SIZE); @@ -590,6 +592,10 @@ DiskQuotaShmemSize(void) if (IS_QUERY_DISPATCHER()) { size = add_size(size, diskquota_launcher_shmem_size()); // DiskquotaLauncherShmem + size = add_size(size, DISKQUOTA_TABLE_SIZE_ENTRY_NUM_SIZE); + size = add_size(size, DISKQUOTA_QUOTA_INFO_ENTRY_NUM_SIZE); + size = add_size(size, hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, TABLE_SIZE_MAP_ENTRY_SIZE)); + size = add_size(size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, QUOTA_INFO_MAP_ENTRY_SIZE)); size = add_size(size, diskquota_worker_shmem_size() * diskquota_max_monitored_databases); } @@ -608,12 +614,6 @@ init_disk_quota_model(uint32 id) bool found; initStringInfo(&str); -#ifdef USE_ASSERT_CHECKING - Assert(DiskquotaLauncherShmem); - - if (!DiskquotaLauncherShmem->isDynamicWorker) Assert(pg_atomic_read_u64(diskquota_shmem_size) >= 0); -#endif - format_name("TableSizeEntrymap", id, &str); memset(&hash_ctl, 0, sizeof(hash_ctl)); hash_ctl.keysize = sizeof(TableSizeEntryKey); @@ -663,10 +663,6 @@ init_disk_quota_model(uint32 id) if (!found) *quota_info_map_last_overflow_report = 0; pfree(str.data); - -#ifdef USE_ASSERT_CHECKING - if (!DiskquotaLauncherShmem->isDynamicWorker) Assert(pg_atomic_read_u64(diskquota_shmem_size) >= 0); -#endif } /* From e4798daac7ac73a57e8ad2ddcb78ad1f038b24ef Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 16 Dec 2025 12:53:51 +0500 Subject: [PATCH 28/41] fix assert --- src/diskquota.h | 2 +- src/diskquota_utility.c | 4 ++-- src/gp_activetable.c | 11 ++++++----- src/quotamodel.c | 16 ++++++++-------- src/relation_cache.c | 4 ++-- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/diskquota.h b/src/diskquota.h index cff3a482..164006e0 100644 --- a/src/diskquota.h +++ b/src/diskquota.h @@ -325,7 +325,7 @@ extern void update_monitordb_status(Oid dbid, uint32 status); extern HTAB *diskquota_hash_create(const char *tabname, long nelem, HASHCTL *info, int flags, DiskquotaHashFunction hashFunction); extern HTAB *DiskquotaShmemInitHash(const char *name, long init_size, long max_size, HASHCTL *infoP, int hash_flags, - DiskquotaHashFunction hash_function); + DiskquotaHashFunction hash_function, bool common_counter); extern void *DiskquotaShmemInitStruct(const char *name, Size size, bool *foundPtr); extern void refresh_monitored_dbid_cache(void); extern HASHACTION check_hash_fullness_num(HTAB *hashp, int num_entries, int max_size, const char *warning_message, diff --git a/src/diskquota_utility.c b/src/diskquota_utility.c index 5ed799ef..89c774dd 100644 --- a/src/diskquota_utility.c +++ b/src/diskquota_utility.c @@ -1645,11 +1645,11 @@ DiskquotaShmemInitHash(const char *name, /* table string name fo long max_size, /* max size of the table */ HASHCTL *infoP, /* info about key and bucket size */ int hash_flags, /* info about infoP */ - DiskquotaHashFunction hashFunction) + DiskquotaHashFunction hashFunction, bool common_counter) { #ifdef USE_ASSERT_CHECKING if (!DiskquotaLauncherShmem || !DiskquotaLauncherShmem->isDynamicWorker) - diskquota_shmem_size_sub(hash_estimate_size(max_size, infoP->entrysize)); + diskquota_shmem_size_sub(hash_estimate_size(common_counter ? init_size : max_size, infoP->entrysize)); #endif #if GP_VERSION_NUM < 70000 diff --git a/src/gp_activetable.c b/src/gp_activetable.c index dba31b30..13e085b1 100644 --- a/src/gp_activetable.c +++ b/src/gp_activetable.c @@ -112,13 +112,14 @@ init_shm_worker_active_tables(void) ctl.keysize = ACTIVE_TABLES_MAP_ENTRY_SIZE; ctl.entrysize = ACTIVE_TABLES_MAP_ENTRY_SIZE; active_tables_map = DiskquotaShmemInitHash("active_tables", diskquota_max_active_tables, - diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); + diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, false); memset(&ctl, 0, sizeof(ctl)); - ctl.keysize = ALTERED_RELOID_CACHE_ENTRY_SIZE; - ctl.entrysize = ALTERED_RELOID_CACHE_ENTRY_SIZE; - altered_reloid_cache = DiskquotaShmemInitHash("altered_reloid_cache", diskquota_max_active_tables, - diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_OID_HASH); + ctl.keysize = ALTERED_RELOID_CACHE_ENTRY_SIZE; + ctl.entrysize = ALTERED_RELOID_CACHE_ENTRY_SIZE; + altered_reloid_cache = + DiskquotaShmemInitHash("altered_reloid_cache", diskquota_max_active_tables, diskquota_max_active_tables, + &ctl, HASH_ELEM, DISKQUOTA_OID_HASH, false); } /* diff --git a/src/quotamodel.c b/src/quotamodel.c index b1892b48..d5263d67 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -490,7 +490,7 @@ disk_quota_shmem_startup(void) hash_ctl.entrysize = DISK_QUOTA_REJECT_MAP_ENTRY_SIZE; disk_quota_reject_map = DiskquotaShmemInitHash("rejectmap whose quota limitation is reached", diskquota_max_local_reject_entries, - MAX_DISK_QUOTA_REJECT_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); + MAX_DISK_QUOTA_REJECT_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, false); init_shm_worker_active_tables(); @@ -502,7 +502,7 @@ disk_quota_shmem_startup(void) monitored_dbid_cache = DiskquotaShmemInitHash("table oid cache which shoud tracking", diskquota_max_monitored_databases, - diskquota_max_monitored_databases, &hash_ctl, HASH_ELEM, DISKQUOTA_OID_HASH); + diskquota_max_monitored_databases, &hash_ctl, HASH_ELEM, DISKQUOTA_OID_HASH, false); if (IS_QUERY_DISPATCHER()) init_launcher_shmem(); LWLockRelease(AddinShmemInitLock); @@ -619,7 +619,7 @@ init_disk_quota_model(uint32 id) hash_ctl.keysize = sizeof(TableSizeEntryKey); hash_ctl.entrysize = TABLE_SIZE_MAP_ENTRY_SIZE; table_size_map = DiskquotaShmemInitHash(str.data, INIT_NUM_TABLE_SIZE_ENTRIES, MAX_NUM_TABLE_SIZE_ENTRIES, - &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); + &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, true); format_name("TableSizeEntrymap_last_overflow_report", id, &str); table_size_map_last_overflow_report = DiskquotaShmemInitStruct(str.data, TABLE_SIZE_MAP_LAST_OVERFLOW_REPORT_SIZE, &found); @@ -643,7 +643,7 @@ init_disk_quota_model(uint32 id) hash_ctl.entrysize = LOCAL_DISK_QUOTA_REJECT_MAP_ENTRY_SIZE; local_disk_quota_reject_map = DiskquotaShmemInitHash(str.data, diskquota_max_local_reject_entries, diskquota_max_local_reject_entries, - &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); + &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, false); format_name("localrejectmap_last_overflow_report", id, &str); local_disk_quota_reject_map_last_overflow_report = @@ -656,7 +656,7 @@ init_disk_quota_model(uint32 id) hash_ctl.entrysize = QUOTA_INFO_MAP_ENTRY_SIZE; hash_ctl.keysize = sizeof(QuotaInfoEntryKey); quota_info_map = DiskquotaShmemInitHash(str.data, INIT_QUOTA_MAP_ENTRIES, MAX_QUOTA_MAP_ENTRIES, &hash_ctl, - HASH_ELEM, DISKQUOTA_TAG_HASH); + HASH_ELEM, DISKQUOTA_TAG_HASH, true); format_name("QuotaInfoMap_last_overflow_report", id, &str); quota_info_map_last_overflow_report = DiskquotaShmemInitStruct(str.data, QUOTA_INFO_MAP_LAST_OVERFLOW_REPORT_SIZE, &found); @@ -696,7 +696,7 @@ vacuum_disk_quota_model(uint32 id) hash_ctl.keysize = sizeof(TableSizeEntryKey); hash_ctl.entrysize = TABLE_SIZE_MAP_ENTRY_SIZE; table_size_map = DiskquotaShmemInitHash(str.data, INIT_NUM_TABLE_SIZE_ENTRIES, MAX_NUM_TABLE_SIZE_ENTRIES, - &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); + &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, true); hash_seq_init(&iter, table_size_map); while ((tsentry = hash_seq_search(&iter)) != NULL) { @@ -716,7 +716,7 @@ vacuum_disk_quota_model(uint32 id) hash_ctl.entrysize = LOCAL_DISK_QUOTA_REJECT_MAP_ENTRY_SIZE; local_disk_quota_reject_map = DiskquotaShmemInitHash(str.data, diskquota_max_local_reject_entries, diskquota_max_local_reject_entries, - &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); + &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, false); hash_seq_init(&iter, local_disk_quota_reject_map); while ((localrejectentry = hash_seq_search(&iter)) != NULL) { @@ -733,7 +733,7 @@ vacuum_disk_quota_model(uint32 id) hash_ctl.entrysize = QUOTA_INFO_MAP_ENTRY_SIZE; hash_ctl.keysize = sizeof(QuotaInfoEntryKey); quota_info_map = DiskquotaShmemInitHash(str.data, INIT_QUOTA_MAP_ENTRIES, MAX_QUOTA_MAP_ENTRIES, &hash_ctl, - HASH_ELEM, DISKQUOTA_TAG_HASH); + HASH_ELEM, DISKQUOTA_TAG_HASH, true); hash_seq_init(&iter, quota_info_map); while ((qentry = hash_seq_search(&iter)) != NULL) { diff --git a/src/relation_cache.c b/src/relation_cache.c index f8af8429..055d0cc6 100644 --- a/src/relation_cache.c +++ b/src/relation_cache.c @@ -56,13 +56,13 @@ init_shm_worker_relation_cache(void) ctl.keysize = sizeof(Oid); ctl.entrysize = RELATION_CACHE_ENTRY_SIZE; relation_cache = DiskquotaShmemInitHash("relation_cache", diskquota_max_active_tables, diskquota_max_active_tables, - &ctl, HASH_ELEM, DISKQUOTA_OID_HASH); + &ctl, HASH_ELEM, DISKQUOTA_OID_HASH, false); memset(&ctl, 0, sizeof(ctl)); ctl.keysize = sizeof(Oid); ctl.entrysize = RELID_CACHE_ENTRY_SIZE; relid_cache = DiskquotaShmemInitHash("relid_cache", diskquota_max_active_tables, diskquota_max_active_tables, &ctl, - HASH_ELEM, DISKQUOTA_OID_HASH); + HASH_ELEM, DISKQUOTA_OID_HASH, false); } Oid From c1fa28ddbf047645d4d959af4a0db5268dc93fc6 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 16 Dec 2025 12:59:46 +0500 Subject: [PATCH 29/41] rm --- src/quotamodel.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index d5263d67..73dba9ae 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -625,16 +625,6 @@ init_disk_quota_model(uint32 id) DiskquotaShmemInitStruct(str.data, TABLE_SIZE_MAP_LAST_OVERFLOW_REPORT_SIZE, &found); if (!found) *table_size_map_last_overflow_report = 0; -#ifdef USE_ASSERT_CHECKING - if (!found) - { - pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(TimestampTz)); // table_size_map_last_overflow_report - pg_atomic_sub_fetch_u64(diskquota_shmem_size, - sizeof(TimestampTz)); // local_disk_quota_reject_map_last_overflow_report - pg_atomic_sub_fetch_u64(diskquota_shmem_size, sizeof(TimestampTz)); // quota_info_map_last_overflow_report - } -#endif - /* for localrejectmap */ /* WARNNING: The max length of name of the map is 48 */ format_name("localrejectmap", id, &str); From e023d8147fa8bc5361111d9a81f35ac7de893639 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 16 Dec 2025 21:01:53 +0500 Subject: [PATCH 30/41] rework --- src/diskquota.c | 17 ++++++++++++++++- src/diskquota.h | 7 ++++++- src/diskquota_utility.c | 32 +++++++++++++++++++++----------- src/gp_activetable.c | 4 ++-- src/quotamodel.c | 31 +++++++++++++++++++++++-------- src/relation_cache.c | 4 ++-- 6 files changed, 70 insertions(+), 25 deletions(-) diff --git a/src/diskquota.c b/src/diskquota.c index 1a0a880f..a2f824e5 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -91,7 +91,7 @@ static DiskQuotaWorkerEntry *volatile MyWorkerInfo = NULL; // how many database diskquota are monitoring on static int num_db = 0; -DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem = NULL; +static DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem; /* how many TableSizeEntry are maintained in all the table_size_map in shared memory */ pg_atomic_uint32 *diskquota_table_size_entry_num; @@ -99,6 +99,11 @@ pg_atomic_uint32 *diskquota_table_size_entry_num; /* how many QuotaInfoEntry are maintained in all the quota_info_map in shared memory */ pg_atomic_uint32 *diskquota_quota_info_entry_num; +#ifdef USE_ASSERT_CHECKING +pg_atomic_flag *diskquota_table_size_flag; +pg_atomic_flag *diskquota_quota_info_flag; +#endif + #define MIN_SLEEPTIME 100 /* milliseconds */ #define BGWORKER_LOG_TIME 3600000 /* milliseconds */ @@ -1787,6 +1792,16 @@ init_launcher_shmem() diskquota_quota_info_entry_num = DiskquotaShmemInitStruct("diskquota QuotaInfoEntry counter", DISKQUOTA_QUOTA_INFO_ENTRY_NUM_SIZE, &found); if (!found) pg_atomic_init_u32(diskquota_quota_info_entry_num, 0); + +#ifdef USE_ASSERT_CHECKING + diskquota_table_size_flag = + DiskquotaShmemInitStruct("diskquota TableSizeEntry flag", DISKQUOTA_TABLE_SIZE_FLAG_SIZE, &found); + if (!found) pg_atomic_init_flag(diskquota_table_size_flag); + + diskquota_quota_info_flag = + DiskquotaShmemInitStruct("diskquota QuotaInfoEntry flag", DISKQUOTA_QUOTA_INFO_FLAG_SIZE, &found); + if (!found) pg_atomic_init_flag(diskquota_quota_info_flag); +#endif } /* diff --git a/src/diskquota.h b/src/diskquota.h index 164006e0..20fe3d4d 100644 --- a/src/diskquota.h +++ b/src/diskquota.h @@ -85,6 +85,11 @@ extern int diskquota_worker_timeout; #define DISKQUOTA_TABLE_SIZE_ENTRY_NUM_SIZE sizeof(pg_atomic_uint32) #define DISKQUOTA_QUOTA_INFO_ENTRY_NUM_SIZE sizeof(pg_atomic_uint32) +#ifdef USE_ASSERT_CHECKING +#define DISKQUOTA_TABLE_SIZE_FLAG_SIZE sizeof(pg_atomic_flag) +#define DISKQUOTA_QUOTA_INFO_FLAG_SIZE sizeof(pg_atomic_flag) +#endif + typedef enum { NAMESPACE_QUOTA = 0, @@ -325,7 +330,7 @@ extern void update_monitordb_status(Oid dbid, uint32 status); extern HTAB *diskquota_hash_create(const char *tabname, long nelem, HASHCTL *info, int flags, DiskquotaHashFunction hashFunction); extern HTAB *DiskquotaShmemInitHash(const char *name, long init_size, long max_size, HASHCTL *infoP, int hash_flags, - DiskquotaHashFunction hash_function, bool common_counter); + DiskquotaHashFunction hash_function, pg_atomic_flag *foundPtr); extern void *DiskquotaShmemInitStruct(const char *name, Size size, bool *foundPtr); extern void refresh_monitored_dbid_cache(void); extern HASHACTION check_hash_fullness_num(HTAB *hashp, int num_entries, int max_size, const char *warning_message, diff --git a/src/diskquota_utility.c b/src/diskquota_utility.c index 89c774dd..f4ec3465 100644 --- a/src/diskquota_utility.c +++ b/src/diskquota_utility.c @@ -115,8 +115,7 @@ static bool to_delete_quota(QuotaType type, int64 quota_limit_mb, float4 segra static void check_role(Oid roleoid, char *rolname, int64 quota_limit_mb); #ifdef USE_ASSERT_CHECKING -extern DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem; -extern void diskquota_shmem_size_sub(Size size); +extern void diskquota_shmem_size_sub(Size size); #endif /* ---- Help Functions to set quota limit. ---- */ @@ -1645,12 +1644,9 @@ DiskquotaShmemInitHash(const char *name, /* table string name fo long max_size, /* max size of the table */ HASHCTL *infoP, /* info about key and bucket size */ int hash_flags, /* info about infoP */ - DiskquotaHashFunction hashFunction, bool common_counter) + DiskquotaHashFunction hashFunction, pg_atomic_flag *foundPtr) { -#ifdef USE_ASSERT_CHECKING - if (!DiskquotaLauncherShmem || !DiskquotaLauncherShmem->isDynamicWorker) - diskquota_shmem_size_sub(hash_estimate_size(common_counter ? init_size : max_size, infoP->entrysize)); -#endif + HTAB *hashp; #if GP_VERSION_NUM < 70000 if (hashFunction == DISKQUOTA_TAG_HASH) @@ -1659,20 +1655,34 @@ DiskquotaShmemInitHash(const char *name, /* table string name fo infoP->hash = oid_hash; else infoP->hash = string_hash; - return ShmemInitHash(name, init_size, max_size, infoP, hash_flags | HASH_FUNCTION); + hashp = ShmemInitHash(name, init_size, max_size, infoP, hash_flags | HASH_FUNCTION); #else - return ShmemInitHash(name, init_size, max_size, infoP, hash_flags | HASH_BLOBS); + hashp = ShmemInitHash(name, init_size, max_size, infoP, hash_flags | HASH_BLOBS); #endif /* GP_VERSION_NUM */ + +#ifdef USE_ASSERT_CHECKING + if (!foundPtr) + diskquota_shmem_size_sub(hash_estimate_size(max_size, infoP->entrysize)); + else if (pg_atomic_unlocked_test_flag(foundPtr)) + { + pg_atomic_test_set_flag(foundPtr); + diskquota_shmem_size_sub(hash_estimate_size(max_size, infoP->entrysize)); + } +#endif + + return hashp; } void * DiskquotaShmemInitStruct(const char *name, Size size, bool *foundPtr) { + void *structPtr = ShmemInitStruct(name, size, foundPtr); + #ifdef USE_ASSERT_CHECKING - if (!DiskquotaLauncherShmem || !DiskquotaLauncherShmem->isDynamicWorker) diskquota_shmem_size_sub(size); + if (!*foundPtr) diskquota_shmem_size_sub(size); #endif - return ShmemInitStruct(name, size, foundPtr); + return structPtr; } HASHACTION diff --git a/src/gp_activetable.c b/src/gp_activetable.c index 13e085b1..f57f093f 100644 --- a/src/gp_activetable.c +++ b/src/gp_activetable.c @@ -112,14 +112,14 @@ init_shm_worker_active_tables(void) ctl.keysize = ACTIVE_TABLES_MAP_ENTRY_SIZE; ctl.entrysize = ACTIVE_TABLES_MAP_ENTRY_SIZE; active_tables_map = DiskquotaShmemInitHash("active_tables", diskquota_max_active_tables, - diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, false); + diskquota_max_active_tables, &ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, NULL); memset(&ctl, 0, sizeof(ctl)); ctl.keysize = ALTERED_RELOID_CACHE_ENTRY_SIZE; ctl.entrysize = ALTERED_RELOID_CACHE_ENTRY_SIZE; altered_reloid_cache = DiskquotaShmemInitHash("altered_reloid_cache", diskquota_max_active_tables, diskquota_max_active_tables, - &ctl, HASH_ELEM, DISKQUOTA_OID_HASH, false); + &ctl, HASH_ELEM, DISKQUOTA_OID_HASH, NULL); } /* diff --git a/src/quotamodel.c b/src/quotamodel.c index 73dba9ae..cb6d0b17 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -95,6 +95,15 @@ extern int diskquota_max_local_reject_entries; extern pg_atomic_uint32 *diskquota_table_size_entry_num; extern pg_atomic_uint32 *diskquota_quota_info_entry_num; + +#ifdef USE_ASSERT_CHECKING +extern pg_atomic_flag *diskquota_table_size_flag; +extern pg_atomic_flag *diskquota_quota_info_flag; +#else +#define diskquota_table_size_flag NULL +#define diskquota_quota_info_flag NULL +#endif + /* * local cache of table disk size and corresponding schema and owner. * @@ -490,7 +499,7 @@ disk_quota_shmem_startup(void) hash_ctl.entrysize = DISK_QUOTA_REJECT_MAP_ENTRY_SIZE; disk_quota_reject_map = DiskquotaShmemInitHash("rejectmap whose quota limitation is reached", diskquota_max_local_reject_entries, - MAX_DISK_QUOTA_REJECT_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, false); + MAX_DISK_QUOTA_REJECT_ENTRIES, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, NULL); init_shm_worker_active_tables(); @@ -502,7 +511,7 @@ disk_quota_shmem_startup(void) monitored_dbid_cache = DiskquotaShmemInitHash("table oid cache which shoud tracking", diskquota_max_monitored_databases, - diskquota_max_monitored_databases, &hash_ctl, HASH_ELEM, DISKQUOTA_OID_HASH, false); + diskquota_max_monitored_databases, &hash_ctl, HASH_ELEM, DISKQUOTA_OID_HASH, NULL); if (IS_QUERY_DISPATCHER()) init_launcher_shmem(); LWLockRelease(AddinShmemInitLock); @@ -594,6 +603,12 @@ DiskQuotaShmemSize(void) size = add_size(size, diskquota_launcher_shmem_size()); // DiskquotaLauncherShmem size = add_size(size, DISKQUOTA_TABLE_SIZE_ENTRY_NUM_SIZE); size = add_size(size, DISKQUOTA_QUOTA_INFO_ENTRY_NUM_SIZE); + +#ifdef USE_ASSERT_CHECKING + size = add_size(size, DISKQUOTA_TABLE_SIZE_FLAG_SIZE); + size = add_size(size, DISKQUOTA_QUOTA_INFO_FLAG_SIZE); +#endif + size = add_size(size, hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, TABLE_SIZE_MAP_ENTRY_SIZE)); size = add_size(size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, QUOTA_INFO_MAP_ENTRY_SIZE)); size = add_size(size, diskquota_worker_shmem_size() * diskquota_max_monitored_databases); @@ -619,7 +634,7 @@ init_disk_quota_model(uint32 id) hash_ctl.keysize = sizeof(TableSizeEntryKey); hash_ctl.entrysize = TABLE_SIZE_MAP_ENTRY_SIZE; table_size_map = DiskquotaShmemInitHash(str.data, INIT_NUM_TABLE_SIZE_ENTRIES, MAX_NUM_TABLE_SIZE_ENTRIES, - &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, true); + &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, diskquota_table_size_flag); format_name("TableSizeEntrymap_last_overflow_report", id, &str); table_size_map_last_overflow_report = DiskquotaShmemInitStruct(str.data, TABLE_SIZE_MAP_LAST_OVERFLOW_REPORT_SIZE, &found); @@ -633,7 +648,7 @@ init_disk_quota_model(uint32 id) hash_ctl.entrysize = LOCAL_DISK_QUOTA_REJECT_MAP_ENTRY_SIZE; local_disk_quota_reject_map = DiskquotaShmemInitHash(str.data, diskquota_max_local_reject_entries, diskquota_max_local_reject_entries, - &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, false); + &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, NULL); format_name("localrejectmap_last_overflow_report", id, &str); local_disk_quota_reject_map_last_overflow_report = @@ -646,7 +661,7 @@ init_disk_quota_model(uint32 id) hash_ctl.entrysize = QUOTA_INFO_MAP_ENTRY_SIZE; hash_ctl.keysize = sizeof(QuotaInfoEntryKey); quota_info_map = DiskquotaShmemInitHash(str.data, INIT_QUOTA_MAP_ENTRIES, MAX_QUOTA_MAP_ENTRIES, &hash_ctl, - HASH_ELEM, DISKQUOTA_TAG_HASH, true); + HASH_ELEM, DISKQUOTA_TAG_HASH, diskquota_quota_info_flag); format_name("QuotaInfoMap_last_overflow_report", id, &str); quota_info_map_last_overflow_report = DiskquotaShmemInitStruct(str.data, QUOTA_INFO_MAP_LAST_OVERFLOW_REPORT_SIZE, &found); @@ -686,7 +701,7 @@ vacuum_disk_quota_model(uint32 id) hash_ctl.keysize = sizeof(TableSizeEntryKey); hash_ctl.entrysize = TABLE_SIZE_MAP_ENTRY_SIZE; table_size_map = DiskquotaShmemInitHash(str.data, INIT_NUM_TABLE_SIZE_ENTRIES, MAX_NUM_TABLE_SIZE_ENTRIES, - &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, true); + &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, diskquota_table_size_flag); hash_seq_init(&iter, table_size_map); while ((tsentry = hash_seq_search(&iter)) != NULL) { @@ -706,7 +721,7 @@ vacuum_disk_quota_model(uint32 id) hash_ctl.entrysize = LOCAL_DISK_QUOTA_REJECT_MAP_ENTRY_SIZE; local_disk_quota_reject_map = DiskquotaShmemInitHash(str.data, diskquota_max_local_reject_entries, diskquota_max_local_reject_entries, - &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, false); + &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, NULL); hash_seq_init(&iter, local_disk_quota_reject_map); while ((localrejectentry = hash_seq_search(&iter)) != NULL) { @@ -723,7 +738,7 @@ vacuum_disk_quota_model(uint32 id) hash_ctl.entrysize = QUOTA_INFO_MAP_ENTRY_SIZE; hash_ctl.keysize = sizeof(QuotaInfoEntryKey); quota_info_map = DiskquotaShmemInitHash(str.data, INIT_QUOTA_MAP_ENTRIES, MAX_QUOTA_MAP_ENTRIES, &hash_ctl, - HASH_ELEM, DISKQUOTA_TAG_HASH, true); + HASH_ELEM, DISKQUOTA_TAG_HASH, diskquota_quota_info_flag); hash_seq_init(&iter, quota_info_map); while ((qentry = hash_seq_search(&iter)) != NULL) { diff --git a/src/relation_cache.c b/src/relation_cache.c index 055d0cc6..f9e32dc7 100644 --- a/src/relation_cache.c +++ b/src/relation_cache.c @@ -56,13 +56,13 @@ init_shm_worker_relation_cache(void) ctl.keysize = sizeof(Oid); ctl.entrysize = RELATION_CACHE_ENTRY_SIZE; relation_cache = DiskquotaShmemInitHash("relation_cache", diskquota_max_active_tables, diskquota_max_active_tables, - &ctl, HASH_ELEM, DISKQUOTA_OID_HASH, false); + &ctl, HASH_ELEM, DISKQUOTA_OID_HASH, NULL); memset(&ctl, 0, sizeof(ctl)); ctl.keysize = sizeof(Oid); ctl.entrysize = RELID_CACHE_ENTRY_SIZE; relid_cache = DiskquotaShmemInitHash("relid_cache", diskquota_max_active_tables, diskquota_max_active_tables, &ctl, - HASH_ELEM, DISKQUOTA_OID_HASH, false); + HASH_ELEM, DISKQUOTA_OID_HASH, NULL); } Oid From 9d0eacaf09efba3fef4e91c93b3c7f1e5019284c Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 16 Dec 2025 21:15:49 +0500 Subject: [PATCH 31/41] fix --- src/diskquota.h | 1 + src/quotamodel.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/diskquota.h b/src/diskquota.h index 20fe3d4d..19262376 100644 --- a/src/diskquota.h +++ b/src/diskquota.h @@ -87,6 +87,7 @@ extern int diskquota_worker_timeout; #ifdef USE_ASSERT_CHECKING #define DISKQUOTA_TABLE_SIZE_FLAG_SIZE sizeof(pg_atomic_flag) +#define LOCAL_DISK_QUOTA_REJECT_FLAG_SIZE sizeof(pg_atomic_flag) #define DISKQUOTA_QUOTA_INFO_FLAG_SIZE sizeof(pg_atomic_flag) #endif diff --git a/src/quotamodel.c b/src/quotamodel.c index cb6d0b17..e23cac20 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -98,9 +98,11 @@ extern pg_atomic_uint32 *diskquota_quota_info_entry_num; #ifdef USE_ASSERT_CHECKING extern pg_atomic_flag *diskquota_table_size_flag; +pg_atomic_flag *dlocal_disk_quota_reject_flag; extern pg_atomic_flag *diskquota_quota_info_flag; #else #define diskquota_table_size_flag NULL +#define dlocal_disk_quota_reject_flag NULL #define diskquota_quota_info_flag NULL #endif @@ -574,6 +576,9 @@ diskquota_worker_shmem_size(void) size = add_size(size, TABLE_SIZE_MAP_LAST_OVERFLOW_REPORT_SIZE); size = add_size(size, LOCAL_DISK_QUOTA_REJECT_MAP_LAST_OVERFLOW_REPORT_SIZE); size = add_size(size, QUOTA_INFO_MAP_LAST_OVERFLOW_REPORT_SIZE); +#ifdef USE_ASSERT_CHECKING + size = add_size(size, LOCAL_DISK_QUOTA_REJECT_FLAG_SIZE); +#endif return size; } @@ -640,6 +645,12 @@ init_disk_quota_model(uint32 id) DiskquotaShmemInitStruct(str.data, TABLE_SIZE_MAP_LAST_OVERFLOW_REPORT_SIZE, &found); if (!found) *table_size_map_last_overflow_report = 0; +#ifdef USE_ASSERT_CHECKING + format_name("diskquota LocalRejectMapEntry flag", id, &str); + dlocal_disk_quota_reject_flag = DiskquotaShmemInitStruct(str.data, LOCAL_DISK_QUOTA_REJECT_FLAG_SIZE, &found); + if (!found) pg_atomic_init_flag(dlocal_disk_quota_reject_flag); +#endif + /* for localrejectmap */ /* WARNNING: The max length of name of the map is 48 */ format_name("localrejectmap", id, &str); @@ -648,7 +659,7 @@ init_disk_quota_model(uint32 id) hash_ctl.entrysize = LOCAL_DISK_QUOTA_REJECT_MAP_ENTRY_SIZE; local_disk_quota_reject_map = DiskquotaShmemInitHash(str.data, diskquota_max_local_reject_entries, diskquota_max_local_reject_entries, - &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, NULL); + &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, dlocal_disk_quota_reject_flag); format_name("localrejectmap_last_overflow_report", id, &str); local_disk_quota_reject_map_last_overflow_report = @@ -714,6 +725,12 @@ vacuum_disk_quota_model(uint32 id) DiskquotaShmemInitStruct(str.data, TABLE_SIZE_MAP_LAST_OVERFLOW_REPORT_SIZE, &found); if (!found) *table_size_map_last_overflow_report = 0; +#ifdef USE_ASSERT_CHECKING + format_name("diskquota LocalRejectMapEntry flag", id, &str); + dlocal_disk_quota_reject_flag = DiskquotaShmemInitStruct(str.data, LOCAL_DISK_QUOTA_REJECT_FLAG_SIZE, &found); + if (!found) pg_atomic_init_flag(dlocal_disk_quota_reject_flag); +#endif + /* localrejectmap */ format_name("localrejectmap", id, &str); memset(&hash_ctl, 0, sizeof(hash_ctl)); @@ -721,7 +738,7 @@ vacuum_disk_quota_model(uint32 id) hash_ctl.entrysize = LOCAL_DISK_QUOTA_REJECT_MAP_ENTRY_SIZE; local_disk_quota_reject_map = DiskquotaShmemInitHash(str.data, diskquota_max_local_reject_entries, diskquota_max_local_reject_entries, - &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, NULL); + &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, dlocal_disk_quota_reject_flag); hash_seq_init(&iter, local_disk_quota_reject_map); while ((localrejectentry = hash_seq_search(&iter)) != NULL) { From e56b228466d7d02cb07838896f95ec6c8eed6e76 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 18 Dec 2025 13:50:19 +0500 Subject: [PATCH 32/41] fix --- src/diskquota_utility.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/diskquota_utility.c b/src/diskquota_utility.c index f4ec3465..8f6e7074 100644 --- a/src/diskquota_utility.c +++ b/src/diskquota_utility.c @@ -1661,13 +1661,10 @@ DiskquotaShmemInitHash(const char *name, /* table string name fo #endif /* GP_VERSION_NUM */ #ifdef USE_ASSERT_CHECKING - if (!foundPtr) - diskquota_shmem_size_sub(hash_estimate_size(max_size, infoP->entrysize)); - else if (pg_atomic_unlocked_test_flag(foundPtr)) - { - pg_atomic_test_set_flag(foundPtr); + AssertImply(IsBackgroundWorker, foundPtr); /* foundPtr only used in background worker */ + + if (!foundPtr || pg_atomic_test_set_flag(foundPtr)) diskquota_shmem_size_sub(hash_estimate_size(max_size, infoP->entrysize)); - } #endif return hashp; From 0d42629f370964a6f9b4c33492940a0c5c3c158f Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 18 Dec 2025 13:52:52 +0500 Subject: [PATCH 33/41] unify --- src/quotamodel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index e23cac20..b3b2a56b 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -303,7 +303,7 @@ update_size_for_quota(int64 size, QuotaType type, Oid *keys, int16 segid) { entry->size = 0; entry->limit = -1; - pg_atomic_add_fetch_u32(diskquota_quota_info_entry_num, 1); + pg_atomic_fetch_add_u32(diskquota_quota_info_entry_num, 1); } entry->size += size; } @@ -331,7 +331,7 @@ update_limit_for_quota(int64 limit, float segratio, QuotaType type, Oid *keys) if (!found) { entry->size = 0; - pg_atomic_add_fetch_u32(diskquota_quota_info_entry_num, 1); + pg_atomic_fetch_add_u32(diskquota_quota_info_entry_num, 1); } if (key.segid == -1) entry->limit = limit; @@ -1011,7 +1011,7 @@ get_table_size_map_entry(Oid oid, int16 segid) int seg_st = TableSizeEntrySegidStart(tsentry); int seg_ed = TableSizeEntrySegidEnd(tsentry); for (int j = seg_st; j < seg_ed; j++) TableSizeEntrySetFlushFlag(tsentry, j); - pg_atomic_add_fetch_u32(diskquota_table_size_entry_num, 1); + pg_atomic_fetch_add_u32(diskquota_table_size_entry_num, 1); } return tsentry; From ec8c4808b9a8c11cb68f825055bc0700f2fd128b Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 18 Dec 2025 13:56:22 +0500 Subject: [PATCH 34/41] avoid mix --- src/diskquota.c | 4 ++-- src/quotamodel.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/diskquota.c b/src/diskquota.c index a2f824e5..c715015c 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -100,8 +100,8 @@ pg_atomic_uint32 *diskquota_table_size_entry_num; pg_atomic_uint32 *diskquota_quota_info_entry_num; #ifdef USE_ASSERT_CHECKING -pg_atomic_flag *diskquota_table_size_flag; -pg_atomic_flag *diskquota_quota_info_flag; +extern pg_atomic_flag *diskquota_table_size_flag; +extern pg_atomic_flag *diskquota_quota_info_flag; #endif #define MIN_SLEEPTIME 100 /* milliseconds */ diff --git a/src/quotamodel.c b/src/quotamodel.c index b3b2a56b..08c76bb8 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -97,9 +97,9 @@ extern pg_atomic_uint32 *diskquota_table_size_entry_num; extern pg_atomic_uint32 *diskquota_quota_info_entry_num; #ifdef USE_ASSERT_CHECKING -extern pg_atomic_flag *diskquota_table_size_flag; -pg_atomic_flag *dlocal_disk_quota_reject_flag; -extern pg_atomic_flag *diskquota_quota_info_flag; +pg_atomic_flag *diskquota_table_size_flag; +pg_atomic_flag *dlocal_disk_quota_reject_flag; +pg_atomic_flag *diskquota_quota_info_flag; #else #define diskquota_table_size_flag NULL #define dlocal_disk_quota_reject_flag NULL From ae2b42af91e6d19fc19c1b00cafd8d450096f4c8 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 18 Dec 2025 14:18:33 +0500 Subject: [PATCH 35/41] fix and reorder --- src/quotamodel.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index 08c76bb8..828c898a 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -568,17 +568,23 @@ init_lwlocks(void) static Size diskquota_worker_shmem_size(void) { - Size size; - size = hash_estimate_size(INIT_NUM_TABLE_SIZE_ENTRIES, TABLE_SIZE_MAP_ENTRY_SIZE); + Size size = 0; + +#ifdef USE_ASSERT_CHECKING + size = add_size(size, LOCAL_DISK_QUOTA_REJECT_FLAG_SIZE); +#endif + + size = add_size(size, hash_estimate_size(INIT_NUM_TABLE_SIZE_ENTRIES / diskquota_max_monitored_databases, + TABLE_SIZE_MAP_ENTRY_SIZE)); size = add_size(size, hash_estimate_size(diskquota_max_local_reject_entries, LOCAL_DISK_QUOTA_REJECT_MAP_ENTRY_SIZE)); - size = add_size(size, hash_estimate_size(INIT_QUOTA_MAP_ENTRIES, QUOTA_INFO_MAP_ENTRY_SIZE)); + size = add_size(size, hash_estimate_size(INIT_QUOTA_MAP_ENTRIES / diskquota_max_monitored_databases, + QUOTA_INFO_MAP_ENTRY_SIZE)); + size = add_size(size, TABLE_SIZE_MAP_LAST_OVERFLOW_REPORT_SIZE); size = add_size(size, LOCAL_DISK_QUOTA_REJECT_MAP_LAST_OVERFLOW_REPORT_SIZE); size = add_size(size, QUOTA_INFO_MAP_LAST_OVERFLOW_REPORT_SIZE); -#ifdef USE_ASSERT_CHECKING - size = add_size(size, LOCAL_DISK_QUOTA_REJECT_FLAG_SIZE); -#endif + return size; } @@ -589,13 +595,13 @@ diskquota_worker_shmem_size(void) static Size DiskQuotaShmemSize(void) { - Size size; - size = EXTENSION_DDL_MESSAGE_SIZE; + Size size = 0; #ifdef USE_ASSERT_CHECKING size = add_size(size, sizeof(pg_atomic_uint64)); // diskquota_shmem_size #endif + size = add_size(size, EXTENSION_DDL_MESSAGE_SIZE); size = add_size(size, hash_estimate_size(MAX_DISK_QUOTA_REJECT_ENTRIES, DISK_QUOTA_REJECT_MAP_ENTRY_SIZE)); size = add_size(size, hash_estimate_size(diskquota_max_active_tables, ACTIVE_TABLES_MAP_ENTRY_SIZE)); size = add_size(size, hash_estimate_size(diskquota_max_active_tables, RELATION_CACHE_ENTRY_SIZE)); From 0aea6f7ee46e07369706f2c3a78efee9a9876f49 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 18 Dec 2025 14:45:53 +0500 Subject: [PATCH 36/41] comments --- src/quotamodel.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index 828c898a..14d8e50e 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -571,18 +571,25 @@ diskquota_worker_shmem_size(void) Size size = 0; #ifdef USE_ASSERT_CHECKING + /* request size for dlocal_disk_quota_reject_flag in each coordinator worker */ size = add_size(size, LOCAL_DISK_QUOTA_REJECT_FLAG_SIZE); #endif + /* request initial size for table_size_map in each coordinator worker */ size = add_size(size, hash_estimate_size(INIT_NUM_TABLE_SIZE_ENTRIES / diskquota_max_monitored_databases, TABLE_SIZE_MAP_ENTRY_SIZE)); + /* request maximum size for local_disk_quota_reject_map in each coordinator worker */ size = add_size(size, hash_estimate_size(diskquota_max_local_reject_entries, LOCAL_DISK_QUOTA_REJECT_MAP_ENTRY_SIZE)); + /* request initial size for quota_info_map in each coordinator worker */ size = add_size(size, hash_estimate_size(INIT_QUOTA_MAP_ENTRIES / diskquota_max_monitored_databases, QUOTA_INFO_MAP_ENTRY_SIZE)); + /* request size for table_size_map_last_overflow_report in each coordinator worker */ size = add_size(size, TABLE_SIZE_MAP_LAST_OVERFLOW_REPORT_SIZE); + /* request size for local_disk_quota_reject_map_last_overflow_report in each coordinator worker */ size = add_size(size, LOCAL_DISK_QUOTA_REJECT_MAP_LAST_OVERFLOW_REPORT_SIZE); + /* request size for quota_info_map_last_overflow_report in each coordinator worker */ size = add_size(size, QUOTA_INFO_MAP_LAST_OVERFLOW_REPORT_SIZE); return size; @@ -598,30 +605,45 @@ DiskQuotaShmemSize(void) Size size = 0; #ifdef USE_ASSERT_CHECKING - size = add_size(size, sizeof(pg_atomic_uint64)); // diskquota_shmem_size + /* request size for diskquota_shmem_size in entire coordinator or segment */ + size = add_size(size, sizeof(pg_atomic_uint64)); #endif + /* request size for extension_ddl_message in entire coordinator or segment */ size = add_size(size, EXTENSION_DDL_MESSAGE_SIZE); + /* request maximum size for disk_quota_reject_map in entire coordinator or segment */ size = add_size(size, hash_estimate_size(MAX_DISK_QUOTA_REJECT_ENTRIES, DISK_QUOTA_REJECT_MAP_ENTRY_SIZE)); + /* request maximum size for active_tables_map in entire coordinator or segment */ size = add_size(size, hash_estimate_size(diskquota_max_active_tables, ACTIVE_TABLES_MAP_ENTRY_SIZE)); + /* request maximum size for relation_cache in entire coordinator or segment */ size = add_size(size, hash_estimate_size(diskquota_max_active_tables, RELATION_CACHE_ENTRY_SIZE)); + /* request maximum size for relid_cache in entire coordinator or segment */ size = add_size(size, hash_estimate_size(diskquota_max_active_tables, RELID_CACHE_ENTRY_SIZE)); + /* request maximum size for altered_reloid_cache in entire coordinator or segment */ size = add_size(size, hash_estimate_size(diskquota_max_active_tables, ALTERED_RELOID_CACHE_ENTRY_SIZE)); + /* request maximum size for monitored_dbid_cache in entire coordinator or segment */ size = add_size(size, hash_estimate_size(diskquota_max_monitored_databases, MONITORED_DBID_CACHE_ENTRY_SIZE)); if (IS_QUERY_DISPATCHER()) { - size = add_size(size, diskquota_launcher_shmem_size()); // DiskquotaLauncherShmem - size = add_size(size, DISKQUOTA_TABLE_SIZE_ENTRY_NUM_SIZE); - size = add_size(size, DISKQUOTA_QUOTA_INFO_ENTRY_NUM_SIZE); - #ifdef USE_ASSERT_CHECKING + /* request size for diskquota_table_size_flag in entire coordinator */ size = add_size(size, DISKQUOTA_TABLE_SIZE_FLAG_SIZE); + /* request size for diskquota_quota_info_flag in entire coordinator */ size = add_size(size, DISKQUOTA_QUOTA_INFO_FLAG_SIZE); #endif + /* request size for DiskquotaLauncherShmem in entire coordinator */ + size = add_size(size, diskquota_launcher_shmem_size()); + /* request size for diskquota_table_size_entry_num in entire coordinator */ + size = add_size(size, DISKQUOTA_TABLE_SIZE_ENTRY_NUM_SIZE); + /* request size for diskquota_quota_info_entry_num in entire coordinator */ + size = add_size(size, DISKQUOTA_QUOTA_INFO_ENTRY_NUM_SIZE); + /* request maximum size for table_size_map in entire coordinator */ size = add_size(size, hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, TABLE_SIZE_MAP_ENTRY_SIZE)); + /* request maximum size for quota_info_map in entire coordinator */ size = add_size(size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, QUOTA_INFO_MAP_ENTRY_SIZE)); + /* request sizes in each coordinator worker */ size = add_size(size, diskquota_worker_shmem_size() * diskquota_max_monitored_databases); } From 3808e3c9e1742f3ecec176bcfc02f264f5d2563d Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 18 Dec 2025 14:49:54 +0500 Subject: [PATCH 37/41] rename --- src/quotamodel.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index 14d8e50e..5fcf3581 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -98,11 +98,11 @@ extern pg_atomic_uint32 *diskquota_quota_info_entry_num; #ifdef USE_ASSERT_CHECKING pg_atomic_flag *diskquota_table_size_flag; -pg_atomic_flag *dlocal_disk_quota_reject_flag; +pg_atomic_flag *local_disk_quota_reject_flag; pg_atomic_flag *diskquota_quota_info_flag; #else #define diskquota_table_size_flag NULL -#define dlocal_disk_quota_reject_flag NULL +#define local_disk_quota_reject_flag NULL #define diskquota_quota_info_flag NULL #endif @@ -571,7 +571,7 @@ diskquota_worker_shmem_size(void) Size size = 0; #ifdef USE_ASSERT_CHECKING - /* request size for dlocal_disk_quota_reject_flag in each coordinator worker */ + /* request size for local_disk_quota_reject_flag in each coordinator worker */ size = add_size(size, LOCAL_DISK_QUOTA_REJECT_FLAG_SIZE); #endif @@ -675,8 +675,8 @@ init_disk_quota_model(uint32 id) #ifdef USE_ASSERT_CHECKING format_name("diskquota LocalRejectMapEntry flag", id, &str); - dlocal_disk_quota_reject_flag = DiskquotaShmemInitStruct(str.data, LOCAL_DISK_QUOTA_REJECT_FLAG_SIZE, &found); - if (!found) pg_atomic_init_flag(dlocal_disk_quota_reject_flag); + local_disk_quota_reject_flag = DiskquotaShmemInitStruct(str.data, LOCAL_DISK_QUOTA_REJECT_FLAG_SIZE, &found); + if (!found) pg_atomic_init_flag(local_disk_quota_reject_flag); #endif /* for localrejectmap */ @@ -687,7 +687,7 @@ init_disk_quota_model(uint32 id) hash_ctl.entrysize = LOCAL_DISK_QUOTA_REJECT_MAP_ENTRY_SIZE; local_disk_quota_reject_map = DiskquotaShmemInitHash(str.data, diskquota_max_local_reject_entries, diskquota_max_local_reject_entries, - &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, dlocal_disk_quota_reject_flag); + &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, local_disk_quota_reject_flag); format_name("localrejectmap_last_overflow_report", id, &str); local_disk_quota_reject_map_last_overflow_report = @@ -755,8 +755,8 @@ vacuum_disk_quota_model(uint32 id) #ifdef USE_ASSERT_CHECKING format_name("diskquota LocalRejectMapEntry flag", id, &str); - dlocal_disk_quota_reject_flag = DiskquotaShmemInitStruct(str.data, LOCAL_DISK_QUOTA_REJECT_FLAG_SIZE, &found); - if (!found) pg_atomic_init_flag(dlocal_disk_quota_reject_flag); + local_disk_quota_reject_flag = DiskquotaShmemInitStruct(str.data, LOCAL_DISK_QUOTA_REJECT_FLAG_SIZE, &found); + if (!found) pg_atomic_init_flag(local_disk_quota_reject_flag); #endif /* localrejectmap */ @@ -766,7 +766,7 @@ vacuum_disk_quota_model(uint32 id) hash_ctl.entrysize = LOCAL_DISK_QUOTA_REJECT_MAP_ENTRY_SIZE; local_disk_quota_reject_map = DiskquotaShmemInitHash(str.data, diskquota_max_local_reject_entries, diskquota_max_local_reject_entries, - &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, dlocal_disk_quota_reject_flag); + &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH, local_disk_quota_reject_flag); hash_seq_init(&iter, local_disk_quota_reject_map); while ((localrejectentry = hash_seq_search(&iter)) != NULL) { From 2e8411591fd94fb1026147a61f16ab53c4574df9 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 18 Dec 2025 15:48:25 +0500 Subject: [PATCH 38/41] fix --- src/quotamodel.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index 5fcf3581..a4d473e8 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -521,8 +521,12 @@ disk_quota_shmem_startup(void) if (IS_QUERY_DISPATCHER()) Assert(pg_atomic_read_u64(diskquota_shmem_size) == diskquota_worker_shmem_size() * diskquota_max_monitored_databases + - hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, TABLE_SIZE_MAP_ENTRY_SIZE) + - hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, QUOTA_INFO_MAP_ENTRY_SIZE)); + hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES - + INIT_NUM_TABLE_SIZE_ENTRIES * diskquota_max_monitored_databases, + TABLE_SIZE_MAP_ENTRY_SIZE) + + hash_estimate_size( + MAX_QUOTA_MAP_ENTRIES - INIT_QUOTA_MAP_ENTRIES * diskquota_max_monitored_databases, + QUOTA_INFO_MAP_ENTRY_SIZE)); else Assert(pg_atomic_read_u64(diskquota_shmem_size) == 0); #endif @@ -576,14 +580,12 @@ diskquota_worker_shmem_size(void) #endif /* request initial size for table_size_map in each coordinator worker */ - size = add_size(size, hash_estimate_size(INIT_NUM_TABLE_SIZE_ENTRIES / diskquota_max_monitored_databases, - TABLE_SIZE_MAP_ENTRY_SIZE)); + size = add_size(size, hash_estimate_size(INIT_NUM_TABLE_SIZE_ENTRIES, TABLE_SIZE_MAP_ENTRY_SIZE)); /* request maximum size for local_disk_quota_reject_map in each coordinator worker */ size = add_size(size, hash_estimate_size(diskquota_max_local_reject_entries, LOCAL_DISK_QUOTA_REJECT_MAP_ENTRY_SIZE)); /* request initial size for quota_info_map in each coordinator worker */ - size = add_size(size, hash_estimate_size(INIT_QUOTA_MAP_ENTRIES / diskquota_max_monitored_databases, - QUOTA_INFO_MAP_ENTRY_SIZE)); + size = add_size(size, hash_estimate_size(INIT_QUOTA_MAP_ENTRIES, QUOTA_INFO_MAP_ENTRY_SIZE)); /* request size for table_size_map_last_overflow_report in each coordinator worker */ size = add_size(size, TABLE_SIZE_MAP_LAST_OVERFLOW_REPORT_SIZE); @@ -640,9 +642,13 @@ DiskQuotaShmemSize(void) /* request size for diskquota_quota_info_entry_num in entire coordinator */ size = add_size(size, DISKQUOTA_QUOTA_INFO_ENTRY_NUM_SIZE); /* request maximum size for table_size_map in entire coordinator */ - size = add_size(size, hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES, TABLE_SIZE_MAP_ENTRY_SIZE)); + size = add_size(size, hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES - INIT_NUM_TABLE_SIZE_ENTRIES * + diskquota_max_monitored_databases, + TABLE_SIZE_MAP_ENTRY_SIZE)); /* request maximum size for quota_info_map in entire coordinator */ - size = add_size(size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES, QUOTA_INFO_MAP_ENTRY_SIZE)); + size = add_size(size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES - + INIT_QUOTA_MAP_ENTRIES * diskquota_max_monitored_databases, + QUOTA_INFO_MAP_ENTRY_SIZE)); /* request sizes in each coordinator worker */ size = add_size(size, diskquota_worker_shmem_size() * diskquota_max_monitored_databases); } From 264e8da29b10f720a6539425a93686d5cbe111bf Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 18 Dec 2025 16:04:08 +0500 Subject: [PATCH 39/41] fix --- src/quotamodel.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index a4d473e8..a0819394 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -519,14 +519,17 @@ disk_quota_shmem_startup(void) #ifdef USE_ASSERT_CHECKING if (IS_QUERY_DISPATCHER()) + { + int table_size_map_size = + MAX_NUM_TABLE_SIZE_ENTRIES - INIT_NUM_TABLE_SIZE_ENTRIES * diskquota_max_monitored_databases; + int quota_info_map_size = MAX_QUOTA_MAP_ENTRIES - INIT_QUOTA_MAP_ENTRIES * diskquota_max_monitored_databases; Assert(pg_atomic_read_u64(diskquota_shmem_size) == diskquota_worker_shmem_size() * diskquota_max_monitored_databases + - hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES - - INIT_NUM_TABLE_SIZE_ENTRIES * diskquota_max_monitored_databases, + hash_estimate_size(table_size_map_size > 0 ? table_size_map_size : 0, TABLE_SIZE_MAP_ENTRY_SIZE) + - hash_estimate_size( - MAX_QUOTA_MAP_ENTRIES - INIT_QUOTA_MAP_ENTRIES * diskquota_max_monitored_databases, - QUOTA_INFO_MAP_ENTRY_SIZE)); + hash_estimate_size(quota_info_map_size > 0 ? quota_info_map_size : 0, + QUOTA_INFO_MAP_ENTRY_SIZE)); + } else Assert(pg_atomic_read_u64(diskquota_shmem_size) == 0); #endif @@ -641,14 +644,17 @@ DiskQuotaShmemSize(void) size = add_size(size, DISKQUOTA_TABLE_SIZE_ENTRY_NUM_SIZE); /* request size for diskquota_quota_info_entry_num in entire coordinator */ size = add_size(size, DISKQUOTA_QUOTA_INFO_ENTRY_NUM_SIZE); + + int table_size_map_size = + MAX_NUM_TABLE_SIZE_ENTRIES - INIT_NUM_TABLE_SIZE_ENTRIES * diskquota_max_monitored_databases; + int quota_info_map_size = MAX_QUOTA_MAP_ENTRIES - INIT_QUOTA_MAP_ENTRIES * diskquota_max_monitored_databases; + /* request maximum size for table_size_map in entire coordinator */ - size = add_size(size, hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES - INIT_NUM_TABLE_SIZE_ENTRIES * - diskquota_max_monitored_databases, - TABLE_SIZE_MAP_ENTRY_SIZE)); + size = add_size( + size, hash_estimate_size(table_size_map_size > 0 ? table_size_map_size : 0, TABLE_SIZE_MAP_ENTRY_SIZE)); /* request maximum size for quota_info_map in entire coordinator */ - size = add_size(size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES - - INIT_QUOTA_MAP_ENTRIES * diskquota_max_monitored_databases, - QUOTA_INFO_MAP_ENTRY_SIZE)); + size = add_size( + size, hash_estimate_size(quota_info_map_size > 0 ? quota_info_map_size : 0, QUOTA_INFO_MAP_ENTRY_SIZE)); /* request sizes in each coordinator worker */ size = add_size(size, diskquota_worker_shmem_size() * diskquota_max_monitored_databases); } From 3fbe56c33b9d1984b3fffe955d3a4e0b409344ff Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 18 Dec 2025 16:08:46 +0500 Subject: [PATCH 40/41] fix --- src/diskquota_utility.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diskquota_utility.c b/src/diskquota_utility.c index 8f6e7074..3a00a185 100644 --- a/src/diskquota_utility.c +++ b/src/diskquota_utility.c @@ -1661,9 +1661,9 @@ DiskquotaShmemInitHash(const char *name, /* table string name fo #endif /* GP_VERSION_NUM */ #ifdef USE_ASSERT_CHECKING - AssertImply(IsBackgroundWorker, foundPtr); /* foundPtr only used in background worker */ + AssertImply(IsBackgroundWorker, foundPtr != NULL); /* foundPtr only used in background worker */ - if (!foundPtr || pg_atomic_test_set_flag(foundPtr)) + if (foundPtr == NULL || pg_atomic_test_set_flag(foundPtr)) diskquota_shmem_size_sub(hash_estimate_size(max_size, infoP->entrysize)); #endif From 4ec3ed9d3894815706df81e067fbe0ad8b720b43 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 18 Dec 2025 16:23:29 +0500 Subject: [PATCH 41/41] optimize --- src/quotamodel.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index a0819394..5989bde8 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -523,12 +523,12 @@ disk_quota_shmem_startup(void) int table_size_map_size = MAX_NUM_TABLE_SIZE_ENTRIES - INIT_NUM_TABLE_SIZE_ENTRIES * diskquota_max_monitored_databases; int quota_info_map_size = MAX_QUOTA_MAP_ENTRIES - INIT_QUOTA_MAP_ENTRIES * diskquota_max_monitored_databases; - Assert(pg_atomic_read_u64(diskquota_shmem_size) == - diskquota_worker_shmem_size() * diskquota_max_monitored_databases + - hash_estimate_size(table_size_map_size > 0 ? table_size_map_size : 0, - TABLE_SIZE_MAP_ENTRY_SIZE) + - hash_estimate_size(quota_info_map_size > 0 ? quota_info_map_size : 0, - QUOTA_INFO_MAP_ENTRY_SIZE)); + int rest_size = diskquota_worker_shmem_size() * diskquota_max_monitored_databases; + + if (table_size_map_size > 0) rest_size += hash_estimate_size(table_size_map_size, TABLE_SIZE_MAP_ENTRY_SIZE); + if (quota_info_map_size > 0) rest_size += hash_estimate_size(quota_info_map_size, QUOTA_INFO_MAP_ENTRY_SIZE); + + Assert(pg_atomic_read_u64(diskquota_shmem_size) == rest_size); } else Assert(pg_atomic_read_u64(diskquota_shmem_size) == 0); @@ -649,12 +649,11 @@ DiskQuotaShmemSize(void) MAX_NUM_TABLE_SIZE_ENTRIES - INIT_NUM_TABLE_SIZE_ENTRIES * diskquota_max_monitored_databases; int quota_info_map_size = MAX_QUOTA_MAP_ENTRIES - INIT_QUOTA_MAP_ENTRIES * diskquota_max_monitored_databases; - /* request maximum size for table_size_map in entire coordinator */ - size = add_size( - size, hash_estimate_size(table_size_map_size > 0 ? table_size_map_size : 0, TABLE_SIZE_MAP_ENTRY_SIZE)); - /* request maximum size for quota_info_map in entire coordinator */ - size = add_size( - size, hash_estimate_size(quota_info_map_size > 0 ? quota_info_map_size : 0, QUOTA_INFO_MAP_ENTRY_SIZE)); + if (table_size_map_size > 0) /* request maximum size for table_size_map in entire coordinator */ + size = add_size(size, hash_estimate_size(table_size_map_size, TABLE_SIZE_MAP_ENTRY_SIZE)); + if (quota_info_map_size > 0) /* request maximum size for quota_info_map in entire coordinator */ + size = add_size(size, hash_estimate_size(quota_info_map_size, QUOTA_INFO_MAP_ENTRY_SIZE)); + /* request sizes in each coordinator worker */ size = add_size(size, diskquota_worker_shmem_size() * diskquota_max_monitored_databases); }