pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix overflow with pgstats DSA reference count 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix overflow with pgstats DSA reference count @ 2024-06-27 00:45 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 3+ messages in thread From: Michael Paquier @ 2024-06-27 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 to automatically release the DSA attached once a backend exits. Not doing any cleanup causes the reference count of the pgstats DSA to continuously increment, at some point overflowing it (the more the number of connections, the faster it is to reach this state). Once the reference count overflows and then gets back to 0, new backends are not able to attach to the pgstats DSA, failing startup. This issue is resolved by adding in the pgstats shutdown hook a call to dsa_release_in_place(), ensuring that the DSA attached at backend startup is correctly released, keeping the reference count at bay. The author of this patch has been able to see this issue on a server with a long uptime and a high connection turnover. Issue introduced by 5891c7a8ed8f, so backpatch down to 15. Author: Anthonin Bonnefoy Discussion: https://postgr.es/m/CAO6_XqqJbJBL=M7Ym13TcB4Xnq58vRa2jcC+gwEPBgbAda6B1Q@mail.gmail.com Backpatch-through: 15 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/7467939ea226ebc5608285486501b136b642c02b Modified Files -------------- src/backend/utils/activity/pgstat_shmem.c | 8 ++++++++ 1 file changed, 8 insertions(+) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix overflow with pgstats DSA reference count @ 2024-06-27 00:45 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 3+ messages in thread From: Michael Paquier @ 2024-06-27 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 to automatically release the DSA attached once a backend exits. Not doing any cleanup causes the reference count of the pgstats DSA to continuously increment, at some point overflowing it (the more the number of connections, the faster it is to reach this state). Once the reference count overflows and then gets back to 0, new backends are not able to attach to the pgstats DSA, failing startup. This issue is resolved by adding in the pgstats shutdown hook a call to dsa_release_in_place(), ensuring that the DSA attached at backend startup is correctly released, keeping the reference count at bay. The author of this patch has been able to see this issue on a server with a long uptime and a high connection turnover. Issue introduced by 5891c7a8ed8f, so backpatch down to 15. Author: Anthonin Bonnefoy Discussion: https://postgr.es/m/CAO6_XqqJbJBL=M7Ym13TcB4Xnq58vRa2jcC+gwEPBgbAda6B1Q@mail.gmail.com Backpatch-through: 15 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/6f61d0e7e2f1395d0a2e06c52b36721cf1656a55 Modified Files -------------- src/backend/utils/activity/pgstat_shmem.c | 8 ++++++++ 1 file changed, 8 insertions(+) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix overflow with pgstats DSA reference count @ 2024-06-27 00:45 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 3+ messages in thread From: Michael Paquier @ 2024-06-27 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 to automatically release the DSA attached once a backend exits. Not doing any cleanup causes the reference count of the pgstats DSA to continuously increment, at some point overflowing it (the more the number of connections, the faster it is to reach this state). Once the reference count overflows and then gets back to 0, new backends are not able to attach to the pgstats DSA, failing startup. This issue is resolved by adding in the pgstats shutdown hook a call to dsa_release_in_place(), ensuring that the DSA attached at backend startup is correctly released, keeping the reference count at bay. The author of this patch has been able to see this issue on a server with a long uptime and a high connection turnover. Issue introduced by 5891c7a8ed8f, so backpatch down to 15. Author: Anthonin Bonnefoy Discussion: https://postgr.es/m/CAO6_XqqJbJBL=M7Ym13TcB4Xnq58vRa2jcC+gwEPBgbAda6B1Q@mail.gmail.com Backpatch-through: 15 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/eb144dfcafdd7fcce817c75db0c353667b819e11 Modified Files -------------- src/backend/utils/activity/pgstat_shmem.c | 8 ++++++++ 1 file changed, 8 insertions(+) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2024-06-27 00:45 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-06-27 00:45 pgsql: Fix overflow with pgstats DSA reference count Michael Paquier <michael@paquier.xyz> 2024-06-27 00:45 pgsql: Fix overflow with pgstats DSA reference count Michael Paquier <michael@paquier.xyz> 2024-06-27 00:45 pgsql: Fix overflow with pgstats DSA reference count Michael Paquier <michael@paquier.xyz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox