Skip to content

Commit d92573a

Browse files
committed
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/[email protected] Discussion: https://postgr.es/m/ZkM30paAD8Cr/[email protected] Backpatch-through: 15
1 parent 8cfbac1 commit d92573a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/utils/activity/pgstat_shmem.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,11 @@ pgstat_drop_entry_internal(PgStatShared_HashEntry *shent,
785785
* backends to release their references.
786786
*/
787787
if (shent->dropped)
788-
elog(ERROR, "can only drop stats once");
788+
elog(ERROR,
789+
"trying to drop stats entry already dropped: kind=%s dboid=%u objoid=%u refcount=%u",
790+
pgstat_get_kind_info(shent->key.kind)->name,
791+
shent->key.dboid, shent->key.objoid,
792+
pg_atomic_read_u32(&shent->refcount));
789793
shent->dropped = true;
790794

791795
/* release refcount marking entry as not dropped */

0 commit comments

Comments
 (0)