Skip to content

Commit

Permalink
few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMurloc committed Nov 30, 2023
1 parent 1e3f233 commit 7158307
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
25 changes: 14 additions & 11 deletions src/diskquota_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -1691,19 +1691,22 @@ void *
shm_hash_enter(HTAB *hashp, const void *keyPtr, bool *foundPtr, int max_size, const char *warning_message,
TimestampTz *last_overflow_report, int guc_value)
{
if (hash_get_num_entries(hashp) >= max_size)
{
return hash_search(hashp, keyPtr, HASH_FIND, foundPtr);
}
void *result = hash_search(hashp, keyPtr, HASH_ENTER, foundPtr);
void *result;
TimestampTz current_time;

if (hash_get_num_entries(hashp) >= max_size) return hash_search(hashp, keyPtr, HASH_FIND, foundPtr);

TimestampTz current_time = GetCurrentTimestamp();
if (hash_get_num_entries(hashp) >= max_size &&
TimestampDifferenceExceeds(*last_overflow_report, current_time,
diskquota_hashmap_overflow_report_timeout * 1000))
result = hash_search(hashp, keyPtr, HASH_ENTER, foundPtr);

if (hash_get_num_entries(hashp) >= max_size)
{
ereport(WARNING, (errmsg(warning_message, guc_value)));
*last_overflow_report = current_time;
current_time = GetCurrentTimestamp();
if (TimestampDifferenceExceeds(*last_overflow_report, current_time,
diskquota_hashmap_overflow_report_timeout * 1000))
{
ereport(WARNING, (errmsg(warning_message, guc_value)));
*last_overflow_report = current_time;
}
}
return result;
}
2 changes: 1 addition & 1 deletion src/gp_activetable.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ typedef struct DiskQuotaSetOFCache
} DiskQuotaSetOFCache;

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

#define ACTIVE_TABLE_ENTER(keyPtr, foundPtr) \
shm_hash_enter(active_tables_map, keyPtr, foundPtr, diskquota_max_active_tables, \
Expand Down

0 comments on commit 7158307

Please sign in to comment.