Skip to content

Commit

Permalink
change macro names
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMurloc committed Dec 14, 2023
1 parent db86b9b commit 652c111
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
2 changes: 2 additions & 0 deletions src/diskquota_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -1699,12 +1699,14 @@ check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message, Time
if (num_entries == max_size)
{
TimestampTz current_time = GetCurrentTimestamp();

if (TimestampDifferenceExceeds(*last_overflow_report, current_time,
diskquota_hashmap_overflow_report_timeout * 1000))
{
ereport(WARNING, (errmsg("%s %d", warning_message, guc_value)));
*last_overflow_report = current_time;
}
}

return HASH_FIND;
}
11 changes: 6 additions & 5 deletions src/gp_activetable.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ typedef struct DiskQuotaSetOFCache
HTAB *active_tables_map = NULL; // Set<DiskQuotaActiveTableFileEntry>
TimestampTz active_tables_last_overflow_report = 0;

#define ACTIVE_TABLE_WARNING \
#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:"
Expand Down Expand Up @@ -333,7 +333,7 @@ report_active_table_helper(const RelFileNodeBackend *relFileNode)
item.tablespaceoid = relFileNode->node.spcNode;

LWLockAcquire(diskquota_locks.active_table_lock, LW_EXCLUSIVE);
HASHACTION action = check_hash_fullness(active_tables_map, diskquota_max_active_tables, ACTIVE_TABLE_WARNING,
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);
entry = hash_search(active_tables_map, &item, action, &found);
if (entry && !found) *entry = item;
Expand Down Expand Up @@ -865,8 +865,9 @@ 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_TABLE_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_last_overflow_report, diskquota_max_active_tables);
hash_search(active_tables_map, active_table_file_entry, action, NULL);
}
/* TODO: hash_seq_term(&iter); */
Expand Down Expand Up @@ -930,7 +931,7 @@ get_active_tables_oid(void)
while ((active_table_file_entry = (DiskQuotaActiveTableFileEntry *)hash_seq_search(&iter)) != NULL)
{
HASHACTION action =
check_hash_fullness(active_tables_map, diskquota_max_active_tables, ACTIVE_TABLE_WARNING,
check_hash_fullness(active_tables_map, diskquota_max_active_tables, ACTIVE_TABLES_MAP_WARNING,
&active_tables_last_overflow_report, diskquota_max_active_tables);
entry = hash_search(active_tables_map, active_table_file_entry, action, &found);
if (entry) *entry = *active_table_file_entry;
Expand Down
28 changes: 14 additions & 14 deletions src/quotamodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Oid quota_key_caches[NUM_QUOTA_TYPES][MAX_NUM_KEYS_QUOTA_MAP] = {
HTAB *quota_info_map;
TimestampTz quota_info_map_last_overflow_report = 0;

#define QUOTA_INFO_WARNING \
#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:"
Expand Down Expand Up @@ -191,7 +191,7 @@ struct LocalRejectMapEntry
static HTAB *table_size_map = NULL;
static TimestampTz table_size_last_overflow_report = 0;

#define TABLE_SIZE_WARNING \
#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:"
Expand All @@ -203,11 +203,11 @@ 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;

#define REJECT_MAP_WARNING \
#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:"

#define LOCAL_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 @@ -254,7 +254,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(quota_info_map, diskquota_max_quota_probes, QUOTA_INFO_WARNING,
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);
entry = hash_search(quota_info_map, &key, action, &found);
/* If the number of quota exceeds the limit, entry will be NULL */
Expand All @@ -281,7 +281,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(quota_info_map, diskquota_max_quota_probes, QUOTA_INFO_WARNING,
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);
entry = hash_search(quota_info_map, &key, action, &found);
/* If the number of quota exceeds the limit, entry will be NULL */
Expand Down Expand Up @@ -312,9 +312,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_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_last_overflow_report, MAX_DISK_QUOTA_REJECT_ENTRIES);
localrejectentry = hash_search(local_disk_quota_reject_map, &keyitem, action, NULL);
if (localrejectentry)
{
Expand Down Expand Up @@ -990,7 +990,7 @@ calculate_table_disk_usage(bool is_init, HTAB *local_active_table_stat_map)
key.reloid = relOid;
key.id = TableSizeEntryId(cur_segid);

HASHACTION action = check_hash_fullness(table_size_map, MAX_NUM_TABLE_SIZE_ENTRIES, TABLE_SIZE_WARNING,
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);
tsentry = hash_search(table_size_map, &key, action, &table_size_map_found);

Expand Down Expand Up @@ -1279,9 +1279,9 @@ flush_local_reject_map(void)
*/
if (localrejectentry->isexceeded)
{
HASHACTION action =
check_hash_fullness(disk_quota_reject_map, MAX_DISK_QUOTA_REJECT_ENTRIES, 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_last_overflow_report, MAX_DISK_QUOTA_REJECT_ENTRIES);
rejectentry = hash_search(disk_quota_reject_map, &localrejectentry->keyitem, action, &found);
if (rejectentry == NULL)
{
Expand Down Expand Up @@ -2119,7 +2119,7 @@ refresh_rejectmap(PG_FUNCTION_ARGS)
if (OidIsValid(rejectmapentry->keyitem.targetoid)) continue;

HASHACTION action =
check_hash_fullness(disk_quota_reject_map, MAX_DISK_QUOTA_REJECT_ENTRIES, REJECT_MAP_WARNING,
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);
new_entry = hash_search(disk_quota_reject_map, &rejectmapentry->keyitem, action, &found);
if (!found && new_entry) memcpy(new_entry, rejectmapentry, sizeof(GlobalRejectMapEntry));
Expand Down

0 comments on commit 652c111

Please sign in to comment.