diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index 056c24c6ee1..8889e4cac26 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -525,9 +525,12 @@ pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, if (shheader == NULL) { /* - * Failed the allocation of a new entry, so clean up the - * shared hashtable before giving up. + * Failed the allocation of a new entry, so clean up both the + * local reference and the shared hashtable before giving up. + * Clean the local state first, since releasing the dshash + * lock can process a pending interrupt. */ + pgstat_release_entry_ref(key, entry_ref, false); dshash_delete_entry(pgStatLocal.shared_hash, shhashent); ereport(ERROR,