Re: shared-memory based stats collector
Started by Ranier Vilelaalmost 4 years ago2 messages
Hi,
Per Coverity.
pgstat_reset_entry does not check if lock it was really blocked.
I think if shared_stat_reset_contents is called without lock,
is it an issue not?
regards,
Ranier Vilela
Attachments:
0001-avoid-reset-stats-without-lock.patchapplication/octet-stream; name=0001-avoid-reset-stats-without-lock.patchDownload
diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c
index b270c504ea..8fb59191ae 100644
--- a/src/backend/utils/activity/pgstat_shmem.c
+++ b/src/backend/utils/activity/pgstat_shmem.c
@@ -920,9 +920,11 @@ pgstat_reset_entry(PgStat_Kind kind, Oid dboid, Oid objoid, TimestampTz ts)
if (!entry_ref || entry_ref->shared_entry->dropped)
return;
- pgstat_lock_entry(entry_ref, false);
- shared_stat_reset_contents(kind, entry_ref->shared_stats, ts);
- pgstat_unlock_entry(entry_ref);
+ if (pgstat_lock_entry(entry_ref, false))
+ {
+ shared_stat_reset_contents(kind, entry_ref->shared_stats, ts);
+ pgstat_unlock_entry(entry_ref);
+ }
}Hi,
On April 8, 2022 4:49:48 AM PDT, Ranier Vilela <ranier.vf@gmail.com> wrote:
Hi,
Per Coverity.
pgstat_reset_entry does not check if lock it was really blocked.
I think if shared_stat_reset_contents is called without lock,
is it an issue not?
I don't think so - the nowait parameter is say to false, so the lock acquisition is blocking.
Andres
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.