Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PG-646: pg_stat_monitor hangs in pgsm_store #432

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions pg_stat_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1776,10 +1776,6 @@

pgsm = pgsm_get_ss();

/*
* We should lock the hash table here what if the bucket is removed; e.g.
* reset is called - HAMID
*/
prev_bucket_id = pg_atomic_read_u64(&pgsm->current_wbucket);
bucketid = get_next_wbucket(pgsm);

Expand Down Expand Up @@ -1882,6 +1878,11 @@

if (shared_hash_entry == NULL)
{
LWLockRelease(pgsm->lock);

Check warning on line 1881 in pg_stat_monitor.c

View check run for this annotation

Codecov / codecov/patch

pg_stat_monitor.c#L1881

Added line #L1881 was not covered by tests

if (DsaPointerIsValid(dsa_query_pointer))
dsa_free(query_dsa_area, dsa_query_pointer);

Check warning on line 1884 in pg_stat_monitor.c

View check run for this annotation

Codecov / codecov/patch

pg_stat_monitor.c#L1884

Added line #L1884 was not covered by tests

/*
* Out of memory; report only if the state has changed now.
* Otherwise we risk filling up the log file with these message.
Expand All @@ -1890,18 +1891,16 @@
{
pgsm->pgsm_oom = true;

ereport(WARNING,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("[pg_stat_monitor] pgsm_store: Hash table is out of memory and can no longer store queries!"),
errdetail("You may reset the view or when the buckets are deallocated, pg_stat_monitor will resume saving " \
"queries. Alternatively, try increasing the value of pg_stat_monitor.pgsm_max.")));
PGSM_DISABLE_ERROR_CAPUTRE();

Check warning on line 1894 in pg_stat_monitor.c

View check run for this annotation

Codecov / codecov/patch

pg_stat_monitor.c#L1894

Added line #L1894 was not covered by tests
{
ereport(WARNING,

Check warning on line 1896 in pg_stat_monitor.c

View check run for this annotation

Codecov / codecov/patch

pg_stat_monitor.c#L1896

Added line #L1896 was not covered by tests
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("[pg_stat_monitor] pgsm_store: Hash table is out of memory and can no longer store queries!"),
errdetail("You may reset the view or when the buckets are deallocated, pg_stat_monitor will resume saving " \
"queries. Alternatively, try increasing the value of pg_stat_monitor.pgsm_max.")));
} PGSM_END_DISABLE_ERROR_CAPTURE();

Check warning on line 1901 in pg_stat_monitor.c

View check run for this annotation

Codecov / codecov/patch

pg_stat_monitor.c#L1901

Added line #L1901 was not covered by tests
}

LWLockRelease(pgsm->lock);

if (DsaPointerIsValid(dsa_query_pointer))
dsa_free(query_dsa_area, dsa_query_pointer);

return;
}
else
Expand Down
Loading