Skip to content

Commit

Permalink
PG-1349 Fix deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
artemgavrilov committed Feb 14, 2025
1 parent d6d6e9e commit 57c609e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pg_stat_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,9 @@ pgsm_store(pgsmEntry *entry)
* we need to create the entry.
*/
LWLockAcquire(pgsm->lock, LW_SHARED);

PG_TRY();
{
shared_hash_entry = (pgsmEntry *) pgsm_hash_find(get_pgsmHash(), &entry->key, &found);

if (!shared_hash_entry)
Expand Down Expand Up @@ -2008,8 +2011,6 @@ pgsm_store(pgsmEntry *entry)
}
PG_CATCH();
{
LWLockRelease(pgsm->lock);

if (DsaPointerIsValid(dsa_query_pointer))
dsa_free(query_dsa_area, dsa_query_pointer);
PG_RE_THROW();
Expand Down Expand Up @@ -2082,6 +2083,15 @@ pgsm_store(pgsmEntry *entry)
PGSM_STORE);

memset(&entry->counters, 0, sizeof(entry->counters));

}
PG_CATCH();

Check warning on line 2088 in pg_stat_monitor.c

View check run for this annotation

Codecov / codecov/patch

pg_stat_monitor.c#L2088

Added line #L2088 was not covered by tests
{
HOLD_INTERRUPTS();
LWLockRelease(pgsm->lock);
PG_RE_THROW();

Check warning on line 2092 in pg_stat_monitor.c

View check run for this annotation

Codecov / codecov/patch

pg_stat_monitor.c#L2090-L2092

Added lines #L2090 - L2092 were not covered by tests
}
PG_END_TRY();
LWLockRelease(pgsm->lock);
}

Expand Down

0 comments on commit 57c609e

Please sign in to comment.