diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index 0005021f644..21bdff106a9 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -1019,7 +1019,7 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) stats_data = MemoryContextAlloc(pgStatLocal.snapshot.context, kind_info->shared_data_len); - pgstat_lock_entry_shared(entry_ref, false); + (void) pgstat_lock_entry_shared(entry_ref, false); memcpy(stats_data, pgstat_get_entry_data(kind, entry_ref->shared_stats), kind_info->shared_data_len); diff --git a/src/backend/utils/activity/pgstat_database.c b/src/backend/utils/activity/pgstat_database.c index fbaf8364117..52d82d25352 100644 --- a/src/backend/utils/activity/pgstat_database.c +++ b/src/backend/utils/activity/pgstat_database.c @@ -195,7 +195,7 @@ pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount) return; } - pgstat_lock_entry(entry_ref, false); + (void) pgstat_lock_entry(entry_ref, false); sharedent = (PgStatShared_Database *) entry_ref->shared_stats; sharedent->stats.checksum_failures += failurecount; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index 5cd24303755..2e33293b000 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -643,6 +643,13 @@ pgstat_release_entry_ref(PgStat_HashKey key, PgStat_EntryRef *entry_ref, pfree(entry_ref); } +/* + * Acquire exclusive lock on the entry. + * + * If nowait is true, it's just a conditional acquire, and the result + * *must* be checked to verify success. + * If nowait is false, waits as necessary, always returning true. + */ bool pgstat_lock_entry(PgStat_EntryRef *entry_ref, bool nowait) { @@ -656,8 +663,10 @@ pgstat_lock_entry(PgStat_EntryRef *entry_ref, bool nowait) } /* + * Acquire shared lock on the entry. + * * Separate from pgstat_lock_entry() as most callers will need to lock - * exclusively. + * exclusively. The wait semantics are identical. */ bool pgstat_lock_entry_shared(PgStat_EntryRef *entry_ref, bool nowait)