]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Keep WAL segments by the flushed value of the slot's restart LSN
authorAlexander Korotkov <akorotkov@postgresql.org>
Sat, 14 Jun 2025 00:33:15 +0000 (03:33 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Sat, 14 Jun 2025 00:53:18 +0000 (03:53 +0300)
commitcea8f2c3e44b5fac59a7298c6b9045c5cbb0eaeb
tree4b195b817813119f2a270cbacb341848acd2cc35
parentc7f25feb3862000a4bc1930aea50ba923be0bdb6
Keep WAL segments by the flushed value of the slot's restart LSN

The patch fixes the issue with the unexpected removal of old WAL segments
after checkpoint, followed by an immediate restart.  The issue occurs when
a slot is advanced after the start of the checkpoint and before old WAL
segments are removed at the end of the checkpoint.

The idea of the patch is to get the minimal restart_lsn at the beginning
of checkpoint (or restart point) creation and use this value when calculating
the oldest LSN for WAL segments removal at the end of checkpoint.  This idea
was proposed by Tomas Vondra in the discussion.  Unlike 291221c46575, this
fix doesn't affect ABI and is intended for back branches.

Discussion: https://postgr.es/m/flat/1d12d2-67235980-35-19a406a0%4063439497
Author: Vitaly Davydov <v.davydov@postgrespro.ru>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Backpatch-through: 13
src/backend/access/transam/xlog.c
src/backend/replication/logical/logical.c
src/backend/replication/walsender.c