Skip to content

Commit

Permalink
rename waribles. remove GUC value from warning messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMurloc committed Dec 22, 2023
1 parent 785fecd commit cb4e1bf
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 63 deletions.
4 changes: 2 additions & 2 deletions src/diskquota.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,6 @@ 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(HTAB *hashp, int max_size, const char *warning_message,
TimestampTz *last_overflow_report, int guc_value);
extern HASHACTION check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message,
TimestampTz *last_overflow_report);
#endif
9 changes: 4 additions & 5 deletions src/diskquota_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -1689,8 +1689,7 @@ DiskquotaShmemInitHash(const char *name, /* table string name fo
* It can be used only under lock.
*/
HASHACTION
check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message, TimestampTz *last_overflow_report,
int guc_value)
check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message, TimestampTz *last_overflow_report)
{
long num_entries = hash_get_num_entries(hashp);

Expand All @@ -1700,10 +1699,10 @@ check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message, Time
{
TimestampTz current_time = GetCurrentTimestamp();

if (TimestampDifferenceExceeds(*last_overflow_report, current_time,
diskquota_hashmap_overflow_report_timeout * 1000))
if (*last_overflow_report == 0 || TimestampDifferenceExceeds(*last_overflow_report, current_time,
diskquota_hashmap_overflow_report_timeout * 1000))
{
ereport(WARNING, (errmsg("%s %d", warning_message, guc_value)));
ereport(WARNING, (errmsg(warning_message)));
*last_overflow_report = current_time;
}
}
Expand Down
31 changes: 13 additions & 18 deletions src/gp_activetable.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ typedef struct DiskQuotaSetOFCache
HASH_SEQ_STATUS pos;
} DiskQuotaSetOFCache;

HTAB *active_tables_map = NULL; // Set<DiskQuotaActiveTableFileEntry>
TimestampTz active_tables_last_overflow_report = 0;
static HTAB *active_tables_map = NULL; // Set<DiskQuotaActiveTableFileEntry>
TimestampTz active_tables_map_last_overflow_report = 0;

#define ACTIVE_TABLES_MAP_WARNING \
"[diskquota] the number of active tables reached the limit, please increase " \
"the GUC value for diskquota.max_active_tables. Current " \
"diskquota.max_active_tables value:"
"the GUC value for diskquota.max_active_tables."

/*
* monitored_dbid_cache is a allow list for diskquota
Expand All @@ -66,13 +65,12 @@ TimestampTz active_tables_last_overflow_report = 0;
* dbid will be added to it when creating diskquota extension
* dbid will be removed from it when droping diskquota extension
*/
HTAB *altered_reloid_cache = NULL; // Set<Oid>
TimestampTz altered_reloid_cache_last_overflow_report = 0;
static HTAB *altered_reloid_cache = NULL; // Set<Oid>
static TimestampTz altered_reloid_cache_last_overflow_report = 0;

#define ALTERED_RELOID_CACHE_WARNING \
"[diskquota] the number of altered reloid cache entries reached the limit, please increase " \
"the GUC value for diskquota.max_active_tables. Current " \
"diskquota.max_active_tables value:"
"the GUC value for diskquota.max_active_tables."

/* active table hooks which detect the disk file size change. */
static file_create_hook_type prev_file_create_hook = NULL;
Expand Down Expand Up @@ -248,9 +246,8 @@ report_altered_reloid(Oid reloid)
if (IsRoleMirror() || IS_QUERY_DISPATCHER()) return;

LWLockAcquire(diskquota_locks.altered_reloid_cache_lock, LW_EXCLUSIVE);
HASHACTION action =
check_hash_fullness(altered_reloid_cache, diskquota_max_active_tables, ALTERED_RELOID_CACHE_WARNING,
&altered_reloid_cache_last_overflow_report, diskquota_max_active_tables);
HASHACTION action = check_hash_fullness(altered_reloid_cache, diskquota_max_active_tables,
ALTERED_RELOID_CACHE_WARNING, &altered_reloid_cache_last_overflow_report);
hash_search(altered_reloid_cache, &reloid, action, NULL);
LWLockRelease(diskquota_locks.altered_reloid_cache_lock);
}
Expand Down Expand Up @@ -334,7 +331,7 @@ report_active_table_helper(const RelFileNodeBackend *relFileNode)

LWLockAcquire(diskquota_locks.active_table_lock, LW_EXCLUSIVE);
HASHACTION action = check_hash_fullness(active_tables_map, diskquota_max_active_tables, ACTIVE_TABLES_MAP_WARNING,
&active_tables_last_overflow_report, diskquota_max_active_tables);
&active_tables_map_last_overflow_report);
entry = hash_search(active_tables_map, &item, action, &found);
if (entry && !found) *entry = item;

Expand Down Expand Up @@ -865,9 +862,8 @@ get_active_tables_oid(void)
hash_seq_init(&iter, local_active_table_file_map);
while ((active_table_file_entry = (DiskQuotaActiveTableFileEntry *)hash_seq_search(&iter)) != NULL)
{
HASHACTION action =
check_hash_fullness(active_tables_map, diskquota_max_active_tables, ACTIVE_TABLES_MAP_WARNING,
&active_tables_last_overflow_report, diskquota_max_active_tables);
HASHACTION action = check_hash_fullness(active_tables_map, diskquota_max_active_tables,
ACTIVE_TABLES_MAP_WARNING, &active_tables_map_last_overflow_report);
hash_search(active_tables_map, active_table_file_entry, action, NULL);
}
/* TODO: hash_seq_term(&iter); */
Expand Down Expand Up @@ -930,9 +926,8 @@ get_active_tables_oid(void)
LWLockAcquire(diskquota_locks.active_table_lock, LW_EXCLUSIVE);
while ((active_table_file_entry = (DiskQuotaActiveTableFileEntry *)hash_seq_search(&iter)) != NULL)
{
HASHACTION action =
check_hash_fullness(active_tables_map, diskquota_max_active_tables, ACTIVE_TABLES_MAP_WARNING,
&active_tables_last_overflow_report, diskquota_max_active_tables);
HASHACTION action = check_hash_fullness(active_tables_map, diskquota_max_active_tables,
ACTIVE_TABLES_MAP_WARNING, &active_tables_map_last_overflow_report);
entry = hash_search(active_tables_map, active_table_file_entry, action, &found);
if (entry) *entry = *active_table_file_entry;
}
Expand Down
2 changes: 0 additions & 2 deletions src/gp_activetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ extern void init_active_table_hook(void);
extern void init_shm_worker_active_tables(void);
extern void init_lock_active_tables(void);

extern HTAB *active_tables_map;
extern HTAB *monitored_dbid_cache;
extern HTAB *altered_reloid_cache;

#ifndef atooid
#define atooid(x) ((Oid)strtoul((x), NULL, 10))
Expand Down
42 changes: 20 additions & 22 deletions src/quotamodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,12 @@ typedef enum
uint16 quota_key_num[NUM_QUOTA_TYPES] = {1, 1, 2, 2, 1};
Oid quota_key_caches[NUM_QUOTA_TYPES][MAX_NUM_KEYS_QUOTA_MAP] = {
{NAMESPACEOID}, {AUTHOID}, {NAMESPACEOID, TABLESPACEOID}, {AUTHOID, TABLESPACEOID}, {TABLESPACEOID}};
HTAB *quota_info_map;
TimestampTz quota_info_map_last_overflow_report = 0;
static HTAB *quota_info_map;
static TimestampTz quota_info_map_last_overflow_report = 0;

#define QUOTA_INFO_MAP_WARNING \
"[diskquota] the number of quota probe reached the limit, please " \
"increase the GUC value for diskquota.max_quota_probes. Current " \
"diskquota.max_quota_probes value:"
"increase the GUC value for diskquota.max_quota_probes."

/* global rejectmap for which exceed their quota limit */
struct RejectMapEntry
Expand Down Expand Up @@ -188,26 +187,25 @@ struct LocalRejectMapEntry
};

/* using hash table to support incremental update the table size entry.*/
static HTAB *table_size_map = NULL;
static TimestampTz table_size_last_overflow_report = 0;
static HTAB *table_size_map = NULL;
static TimestampTz table_size_map_last_overflow_report = 0;

#define TABLE_SIZE_MAP_WARNING \
"[diskquota] the number of tables reached the limit, please increase " \
"the GUC value for diskquota.max_table_segments. Current " \
"diskquota.max_table_segments value:"
"the GUC value for diskquota.max_table_segments."

/* rejectmap for database objects which exceed their quota limit */
static HTAB *disk_quota_reject_map = NULL;
static HTAB *local_disk_quota_reject_map = NULL;

static TimestampTz disk_quota_reject_last_overflow_report = 0;
static TimestampTz local_disk_quota_reject_last_overflow_report = 0;
static TimestampTz disk_quota_reject_map_last_overflow_report = 0;
static TimestampTz local_disk_quota_reject_map_last_overflow_report = 0;

#define DISK_QUOTA_REJECT_MAP_WARNING \
"[diskquota] Shared disk quota reject map size limit reached. " \
"Some out-of-limit schemas or roles will be lost in rejectmap. Current limit:"
"Some out-of-limit schemas or roles will be lost in rejectmap."

#define LOCAL_DISK_QUOTA_REJECT_MAP_WARNING "[diskquota] the number of local reject map entries reached the limit:"
#define LOCAL_DISK_QUOTA_REJECT_MAP_WARNING "[diskquota] the number of local reject map entries reached the limit."

static shmem_startup_hook_type prev_shmem_startup_hook = NULL;

Expand Down Expand Up @@ -255,7 +253,7 @@ update_size_for_quota(int64 size, QuotaType type, Oid *keys, int16 segid)
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, diskquota_max_quota_probes);
&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;
Expand All @@ -282,7 +280,7 @@ update_limit_for_quota(int64 limit, float segratio, QuotaType type, Oid *keys)
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, diskquota_max_quota_probes);
&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;
Expand Down Expand Up @@ -312,9 +310,9 @@ add_quota_to_rejectmap(QuotaType type, Oid targetOid, Oid tablespaceoid, bool se
keyitem.tablespaceoid = tablespaceoid;
keyitem.targettype = (uint32)type;
ereport(DEBUG1, (errmsg("[diskquota] Put object %u to rejectmap", targetOid)));
HASHACTION action = check_hash_fullness(
local_disk_quota_reject_map, MAX_DISK_QUOTA_REJECT_ENTRIES, LOCAL_DISK_QUOTA_REJECT_MAP_WARNING,
&local_disk_quota_reject_last_overflow_report, MAX_DISK_QUOTA_REJECT_ENTRIES);
HASHACTION action =
check_hash_fullness(local_disk_quota_reject_map, MAX_DISK_QUOTA_REJECT_ENTRIES,
LOCAL_DISK_QUOTA_REJECT_MAP_WARNING, &local_disk_quota_reject_map_last_overflow_report);
localrejectentry = hash_search(local_disk_quota_reject_map, &keyitem, action, NULL);
if (localrejectentry)
{
Expand Down Expand Up @@ -991,7 +989,7 @@ calculate_table_disk_usage(bool is_init, HTAB *local_active_table_stat_map)
key.id = TableSizeEntryId(cur_segid);

HASHACTION action = check_hash_fullness(table_size_map, MAX_NUM_TABLE_SIZE_ENTRIES, TABLE_SIZE_MAP_WARNING,
&table_size_last_overflow_report, diskquota_max_table_segments);
&table_size_map_last_overflow_report);
tsentry = hash_search(table_size_map, &key, action, &table_size_map_found);

if (!table_size_map_found)
Expand Down Expand Up @@ -1279,9 +1277,9 @@ flush_local_reject_map(void)
*/
if (localrejectentry->isexceeded)
{
HASHACTION action = check_hash_fullness(
disk_quota_reject_map, MAX_DISK_QUOTA_REJECT_ENTRIES, DISK_QUOTA_REJECT_MAP_WARNING,
&disk_quota_reject_last_overflow_report, MAX_DISK_QUOTA_REJECT_ENTRIES);
HASHACTION action =
check_hash_fullness(disk_quota_reject_map, MAX_DISK_QUOTA_REJECT_ENTRIES,
DISK_QUOTA_REJECT_MAP_WARNING, &disk_quota_reject_map_last_overflow_report);
rejectentry = hash_search(disk_quota_reject_map, &localrejectentry->keyitem, action, &found);
if (rejectentry == NULL)
{
Expand Down Expand Up @@ -2120,7 +2118,7 @@ refresh_rejectmap(PG_FUNCTION_ARGS)

HASHACTION action =
check_hash_fullness(disk_quota_reject_map, MAX_DISK_QUOTA_REJECT_ENTRIES, DISK_QUOTA_REJECT_MAP_WARNING,
&disk_quota_reject_last_overflow_report, MAX_DISK_QUOTA_REJECT_ENTRIES);
&disk_quota_reject_map_last_overflow_report);
new_entry = hash_search(disk_quota_reject_map, &rejectmapentry->keyitem, action, &found);
if (!found && new_entry) memcpy(new_entry, rejectmapentry, sizeof(GlobalRejectMapEntry));
}
Expand Down
12 changes: 5 additions & 7 deletions src/relation_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@
HTAB *relation_cache = NULL;
HTAB *relid_cache = NULL;

extern TimestampTz active_tables_last_overflow_report;
extern TimestampTz active_tables_map_last_overflow_report;

#define RELATION_CACHE_WARNING \
"[diskquota] the number of relation cache entries reached the limit, please increase " \
"the GUC value for diskquota.max_active_tables. Current " \
"diskquota.max_active_tables value:"
"the GUC value for diskquota.max_active_tables."

#define RELID_CACHE_WARNING \
"[diskquota] the number of relation cache entries reached the limit, please increase " \
"the GUC value for diskquota.max_active_tables. Current " \
"diskquota.max_active_tables value:"
"the GUC value for diskquota.max_active_tables."

static void update_relation_entry(Oid relid, DiskQuotaRelationCacheEntry *relation_entry,
DiskQuotaRelidCacheEntry *relid_entry);
Expand Down Expand Up @@ -192,7 +190,7 @@ update_relation_cache(Oid relid)
LWLockAcquire(diskquota_locks.relation_cache_lock, LW_EXCLUSIVE);

action = check_hash_fullness(relation_cache, diskquota_max_active_tables, RELATION_CACHE_WARNING,
&active_tables_last_overflow_report, diskquota_max_active_tables);
&active_tables_map_last_overflow_report);
relation_entry = hash_search(relation_cache, &relation_entry_data.relid, action, NULL);

if (relation_entry == NULL)
Expand All @@ -203,7 +201,7 @@ update_relation_cache(Oid relid)
memcpy(relation_entry, &relation_entry_data, sizeof(DiskQuotaRelationCacheEntry));

action = check_hash_fullness(relid_cache, diskquota_max_active_tables, RELID_CACHE_WARNING,
&active_tables_last_overflow_report, diskquota_max_active_tables);
&active_tables_map_last_overflow_report);
relid_entry = hash_search(relid_cache, &relid_entry_data.relfilenode, action, NULL);
if (relid_entry == NULL)
{
Expand Down
9 changes: 2 additions & 7 deletions tests/regress/expected/test_activetable_limit.out
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ NOTICE: CREATE TABLE will create partition "t1_1_prt_7" for table "t1"
NOTICE: CREATE TABLE will create partition "t1_1_prt_8" for table "t1"
NOTICE: CREATE TABLE will create partition "t1_1_prt_9" for table "t1"
NOTICE: CREATE TABLE will create partition "t1_1_prt_10" for table "t1"
WARNING: [diskquota] the number of active tables reached the limit, please increase the GUC value for diskquota.max_active_tables. Current diskquota.max_active_tables value: 5
WARNING: [diskquota] the number of active tables reached the limit, please increase the GUC value for diskquota.max_active_tables. Current diskquota.max_active_tables value: 5 (seg0 127.0.1.1:6002 pid=195302)
WARNING: [diskquota] the number of active tables reached the limit, please increase the GUC value for diskquota.max_active_tables. Current diskquota.max_active_tables value: 5 (seg1 127.0.1.1:6003 pid=195303)
WARNING: [diskquota] the number of active tables reached the limit, please increase the GUC value for diskquota.max_active_tables. Current diskquota.max_active_tables value: 5 (seg2 127.0.1.1:6004 pid=195304)
WARNING: [diskquota] the number of active tables reached the limit, please increase the GUC value for diskquota.max_active_tables.
SELECT count(*) FROM segment_logs WHERE line LIKE '%the number of active tables reached the limit%';
count
-------
Expand All @@ -70,9 +67,7 @@ SELECT count(*) FROM s.t1;

-- altered reloid cache overflow check. expected warning.
VACUUM FULL;
WARNING: [diskquota] the number of altered reloid cache entries reached the limit, please increase the GUC value for diskquota.max_active_tables. Current diskquota.max_active_tables value: 5 (seg2 127.0.1.1:6004 pid=195304)
WARNING: [diskquota] the number of altered reloid cache entries reached the limit, please increase the GUC value for diskquota.max_active_tables. Current diskquota.max_active_tables value: 5 (seg0 127.0.1.1:6002 pid=195302)
WARNING: [diskquota] the number of altered reloid cache entries reached the limit, please increase the GUC value for diskquota.max_active_tables. Current diskquota.max_active_tables value: 5 (seg1 127.0.1.1:6003 pid=195303)
WARNING: [diskquota] the number of altered reloid cache entries reached the limit, please increase the GUC value for diskquota.max_active_tables.
SELECT count(*) FROM segment_logs WHERE line LIKE '%the number of altered reloid cache entries reached the limit%';
count
-------
Expand Down

0 comments on commit cb4e1bf

Please sign in to comment.