Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7467939

Browse files
committed
Fix overflow with pgstats DSA reference count
When pgstats is initialized for a backend, it uses dsa_attach_in_place()without a "segment" provided. Hence, no callback is registered toautomatically release the DSA attached once a backend exits. Not doingany cleanup causes the reference count of the pgstats DSA tocontinuously increment, at some point overflowing it (the more thenumber of connections, the faster it is to reach this state). Once thereference count overflows and then gets back to 0, new backends are notable to attach to the pgstats DSA, failing startup.This issue is resolved by adding in the pgstats shutdown hook a call todsa_release_in_place(), ensuring that the DSA attached at backendstartup is correctly released, keeping the reference count at bay.The author of this patch has been able to see this issue on a serverwith a long uptime and a high connection turnover.Issue introduced by5891c7a, so backpatch down to 15.Author: Anthonin BonnefoyDiscussion:https://postgr.es/m/CAO6_XqqJbJBL=M7Ym13TcB4Xnq58vRa2jcC+gwEPBgbAda6B1Q@mail.gmail.comBackpatch-through: 15
1 parentb1ffe3f commit7467939

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎src/backend/utils/activity/pgstat_shmem.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,14 @@ pgstat_detach_shmem(void)
246246
pgStatLocal.shared_hash=NULL;
247247

248248
dsa_detach(pgStatLocal.dsa);
249+
250+
/*
251+
* dsa_detach() does not decrement the DSA reference count as no segment
252+
* was provided to dsa_attach_in_place(), causing no cleanup callbacks to
253+
* be registered. Hence, release it manually now.
254+
*/
255+
dsa_release_in_place(pgStatLocal.shmem->raw_dsa_area);
256+
249257
pgStatLocal.dsa=NULL;
250258
}
251259

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp