agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Checkpoint replication slots later in the checkpoint cycle
Date: Tue, 04 Aug 2026 08:09:43 +0000
Message-ID: <E1wrADX-000000008UC-3jaW@gemulon.postgresql.org> (raw)
Checkpoint replication slots later in the checkpoint cycle
Previously, CheckPointReplicationSlots() ran at the start of
CheckPointGuts(), while WAL cleanup occurred much later in
CreateCheckPoint() and CreateRestartPoint(), after the buffer write
and ProcessSyncRequests() phases. During a spread checkpoint, this gap
could be several minutes.
During that time, active replication slots could advance their
restart_lsn. However, replicationSlotMinLSN had already been
computed from the older saved values. As a result, KeepLogSeg() could
retain WAL segments that were no longer needed, causing unnecessary
pg_wal growth until the next checkpoint or restartpoint.
Fix this by moving CheckPointReplicationSlots(),
CheckPointSnapBuild(), and CheckPointLogicalRewriteHeap() to just
before CheckPointTwoPhase(), after the buffer write and
ProcessSyncRequests() phases. This makes WAL retention decisions use
the latest replication slot state. The logical snapshot and rewrite heap
cleanup decisions also benefit from the updated saved restart_lsn.
Author: Ants Aasma <ants@cybertec.at>
Author: Hüseyin Demir <huseyin.d3r@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CANwKhkPCBcTQ_pk06MD5W5YYNnuYHp8dLNuOUz8-5pMBMPY1Bw%40mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/69ed7fd7e9da1cff2f04af04f630287971fe99fe
Modified Files
--------------
src/backend/access/transam/xlog.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
Message-ID: <E1wrADX-000000008UC-3jaW@gemulon.postgresql.org>
Permalink: ../E1wrADX-000000008UC-3jaW@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wrADX-000000008UC-3jaW@gemulon.postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: fujii@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Checkpoint replication slots later in the checkpoint cycle
In-Reply-To: <E1wrADX-000000008UC-3jaW@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox