Skip to content

Commit

Permalink
PG-501: Missing Buckets and incorrect calls count.
Browse files Browse the repository at this point in the history
Ensuring the outer bound for the bucket is an exclusive boundary and it
as it belongs to the next bucket. To explain the point further, a set of
five second bucket would be:
    Bucket 1: 00:00:00.00 -> 00:00:04.99...
    Bucket 2: 00:00:00.05 -> 00:00:09.99...
    Bucket 3: 00:00:00.10 -> 00:00:14.99...
    ...
  • Loading branch information
Hamid Akhtar authored and codeforall committed Aug 30, 2022
1 parent bb5e6a4 commit 8e4dc94
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pg_stat_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@ get_next_wbucket(pgssSharedState *pgss)
* definitely make the while condition to fail, we can stop the loop as
* another thread has already updated prev_bucket_sec.
*/
while ((tv.tv_sec - (uint)current_bucket_sec) > ((uint)PGSM_BUCKET_TIME))
while ((tv.tv_sec - (uint)current_bucket_sec) >= ((uint)PGSM_BUCKET_TIME))
{
if (pg_atomic_compare_exchange_u64(&pgss->prev_bucket_sec, &current_bucket_sec, (uint64)tv.tv_sec))
{
Expand Down

0 comments on commit 8e4dc94

Please sign in to comment.