aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-06-07 18:46:34 +0900
committerMichael Paquier <michael@paquier.xyz>2024-06-07 18:46:34 +0900
commit2de059de2c2dbc9324deb304b625d1619af03a6c (patch)
tree1f4f8a0851a7cd292f62718e24597dc1f9678360
parentb33c141cc52b5dfdf06dea1c36874a5842bada8f (diff)
downloadpostgresql-2de059de2c2dbc9324deb304b625d1619af03a6c.tar.gz
postgresql-2de059de2c2dbc9324deb304b625d1619af03a6c.zip
Add more debugging information when dropping twice pgstats entry
Floris Van Nee has reported a bug in the pgstats facility where a stats entry already dropped would get again dropped. This case should not happen, still the error generated did not offer any details about the stats entry getting dropped. This commit improves the error message generated to inform about the stats entry kind, database OID, object OID and refcount, which should help to debug more the problem reported. Bertrand Drouvot has been independently able to reach this error path while writing a new feature, and more details about the failure would have been helpful for debugging. Author: Andres Freund, Bertrand Drouvot Discussion: https://postgr.es/m/20240505160915.6boysum4f34siqct@awork3.anarazel.de Discussion: https://postgr.es/m/ZkM30paAD8Cr/Bix@ip-10-97-1-34.eu-west-3.compute.internal Backpatch-through: 15
-rw-r--r--src/backend/utils/activity/pgstat_shmem.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c
index 9e4ea2e0428..cee0bd60234 100644
--- a/src/backend/utils/activity/pgstat_shmem.c
+++ b/src/backend/utils/activity/pgstat_shmem.c
@@ -780,7 +780,11 @@ pgstat_drop_entry_internal(PgStatShared_HashEntry *shent,
* backends to release their references.
*/
if (shent->dropped)
- elog(ERROR, "can only drop stats once");
+ elog(ERROR,
+ "trying to drop stats entry already dropped: kind=%s dboid=%u objoid=%u refcount=%u",
+ pgstat_get_kind_info(shent->key.kind)->name,
+ shent->key.dboid, shent->key.objoid,
+ pg_atomic_read_u32(&shent->refcount));
shent->dropped = true;
/* release refcount marking entry as not dropped */