Fix oldest LSN calculation for WAL segments removal when slots are advancing during checkpoint

Edit
ID 5627
Title Fix oldest LSN calculation for WAL segments removal when slots are advancing during checkpoint
CI (CFBot) Needs rebase! Needs rebase since 6 months. Failing since 7 months.
Additional links previous successfully applied patch (outdated):
Summary
Stats (from CFBot) Unknown
Tags Bugfix
Created 2025-03-03 14:53:27
Last modified 2026-02-03 22:29:27 (1 hour ago)
Latest email 2025-07-21 12:09:05 (6 months ago)
Status
PG19-1 (2025-07-01 – 2025-07-31): Committed
Target version
Authors Vitaly Davydov (vitprof)
Reviewers Become reviewer
Committer Alexander Korotkov (smagen)
Links
Emails
Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly
First at 2024-10-31 10:18:34 by "Vitaly Davydov" <v.davydov at postgrespro.ru>
Latest at 2025-07-18 11:41:31 by Alexander Korotkov <aekorotkov at gmail.com>
Latest attachment (physical_replication_restart_lsn_backward.patch) at 2025-07-02 17:20:22 from vignesh C <vignesh21 at gmail.com>
    Attachment (physical_replication_restart_lsn_backward.patch) at 2025-07-02 17:20:22 from vignesh C <vignesh21 at gmail.com> (Patch: Yes)
    Attachment (0001-Update-comment-for-last_saved_restart_lsn.patch) at 2025-06-29 06:22:30 from "Hayato Kuroda (Fujitsu)" <kuroda.hayato at fujitsu.com> (Patch: Yes)
    Attachment (v1-0001-Fix-CheckPointReplicationSlots-with-max_replicati.patch) at 2025-06-25 21:50:29 from Alexander Korotkov <aekorotkov at gmail.com> (Patch: Yes)
    Attachment (tmp.diffs) at 2025-06-25 07:48:43 from "Hayato Kuroda (Fujitsu)" <kuroda.hayato at fujitsu.com> (Patch: Yes)
    Attachment (v5-0001-Remove-excess-assert-from-InvalidatePossiblyObsol.patch) at 2025-06-22 23:05:59 from Alexander Korotkov <aekorotkov at gmail.com> (Patch: Yes)
    Attachment (restart_lsn_backup_repro_v1.patch) at 2025-06-20 12:41:57 from vignesh C <vignesh21 at gmail.com> (Patch: Yes)
    Attachment (v4-0002-Remove-excess-assert-from-InvalidatePossiblyObsol.patch) at 2025-06-18 16:47:09 from Alexander Korotkov <aekorotkov at gmail.com> (Patch: Yes)
    Attachment (v3-0001-Improve-runtime-and-output-of-tests-for-replicati.patch) at 2025-06-16 11:16:42 from Alexander Korotkov <aekorotkov at gmail.com> (Patch: Yes)
    Attachment (v2-0001-Improve-runtime-and-output-of-tests-for-replicati.patch) at 2025-06-16 01:58:51 from Alexander Korotkov <aekorotkov at gmail.com> (Patch: Yes)
    Attachment (v1-0001-Fix-046_checkpoint_-logical-physical-_slot.pl-exe.patch) at 2025-06-15 11:02:44 from Alexander Korotkov <aekorotkov at gmail.com> (Patch: Yes)
    Attachment (v3-0001-Keep-WAL-segments-by-slot-s-flushed-restart-LSN.patch) at 2025-06-10 20:14:16 from Alexander Korotkov <aekorotkov at gmail.com> (Patch: Yes)
    Attachment (v2-0001-Keep-WAL-segments-by-slot-s-flushed-restart-LSN.patch) at 2025-06-03 13:21:19 from Alexander Korotkov <aekorotkov at gmail.com> (Patch: Yes)
    Attachment (v7-0003-Remove-redundant-ReplicationSlotsComputeRequiredLSN-.patch) at 2025-05-26 10:22:51 from "Vitaly Davydov" <v.davydov at postgrespro.ru> (Patch: Yes)
    Attachment (v6-0003-Remove-redundant-ReplicationSlotsComputeRequiredL.patch) at 2025-05-24 13:28:55 from Alexander Korotkov <aekorotkov at gmail.com> (Patch: Yes)
    Attachment (v5-0003-Remove-redundant-ReplicationSlotsComputeRequiredL.patch) at 2025-05-24 10:37:52 from Alexander Korotkov <aekorotkov at gmail.com> (Patch: Yes)
    Attachment (v4-0001-Keep-WAL-segments-by-the-flushed-value-of-the-slo.patch) at 2025-05-22 21:10:27 from Alexander Korotkov <aekorotkov at gmail.com> (Patch: Yes)
    Attachment (0002-Add-TAP-test-to-check-logical-repl-slot-advance-duri.v3.patch) at 2025-05-20 15:44:44 from "Vitaly Davydov" <v.davydov at postgrespro.ru> (Patch: Yes)
    Attachment (0003-Add-TAP-test-to-check-physical-repl-slot-advance-dur.v2.patch) at 2025-05-02 17:47:48 from "Vitaly Davydov" <v.davydov at postgrespro.ru> (Patch: Yes)
    Attachment (0001-Keep-WAL-segments-by-slot-s-flushed-restart-LSN.patch) at 2025-03-03 15:12:12 from "Vitaly Davydov" <v.davydov at postgrespro.ru> (Patch: Yes)
    Attachment (0001-Keep-WAL-segments-by-slot-s-flushed-restart-LSN.patch) at 2024-12-13 14:34:01 from "Vitaly Davydov" <v.davydov at postgrespro.ru> (Patch: Yes)
    Attachment (0002-TAP-test.patch) at 2024-11-21 23:05:40 from Tomas Vondra <tomas at vondra.me> (Patch: Yes)
    Attachment (restartlsn.pl) at 2024-11-21 16:13:23 from Давыдов Виталий <v.davydov at postgrespro.ru> (Patch: No)
    Attachment (0001-Keep-WAL-segments-by-slot-s-flushed-restart-LSN.patch) at 2024-11-07 13:30:39 from "Vitaly Davydov" <v.davydov at postgrespro.ru> (Patch: Yes)
    Attachment (0001-Keep-WAL-segments-by-slot-s-flushed-restart-LSN.patch) at 2024-10-31 10:32:36 from "Vitaly Davydov" <v.davydov at postgrespro.ru> (Patch: Yes)
Document slot's restart_lsn can go backward
First at 2025-07-18 11:40:49 by Alexander Korotkov <aekorotkov at gmail.com>
Latest at 2025-07-21 12:09:05 by Alexander Korotkov <aekorotkov at gmail.com>
Latest attachment (v2-0001-Update-comment-for-last_saved_restart_lsn.patch) at 2025-07-21 05:34:15 from Amit Kapila <amit.kapila16 at gmail.com>
    Attachment (v2-0001-Update-comment-for-last_saved_restart_lsn.patch) at 2025-07-21 05:34:15 from Amit Kapila <amit.kapila16 at gmail.com> (Patch: Yes)
    Attachment (0001-Update-comment-for-last_saved_restart_lsn.patch) at 2025-07-18 11:40:49 from Alexander Korotkov <aekorotkov at gmail.com> (Patch: Yes)
History
When Who What
2026-02-03 22:29:27 Álvaro Herrera (alvherre) Closed in commitfest PG19-1 with status: Committed
2026-02-03 22:29:27 Álvaro Herrera (alvherre) Changed committer to smagen
2026-02-03 22:29:19 Álvaro Herrera (alvherre) Attached mail thread CAPpHfdvuyMrUg0Vs5jPfwLOo1M9B-GP5j_My9URnBX0B=nrHKw@mail.gmail.com
2025-07-08 02:38:24 CFbot Patch needs rebase
2025-06-30 02:38:06 Hayato Kuroda (ha-kun) Removed ha-kun from reviewers
2025-06-30 02:36:58 Hayato Kuroda (ha-kun) Added ha-kun as reviewer
2025-06-29 06:39:51 CFbot Patch does not need rebase anymore
2025-06-28 06:50:38 CFbot Patch needs rebase
2025-05-21 19:11:35 CFbot Patch does not need rebase anymore
2025-05-20 00:32:29 CFbot Patch needs rebase
2025-03-03 16:35:05 Vitaly Davydov (vitprof) New status: Needs review
2025-03-03 14:56:05 Vitaly Davydov (vitprof) New status: Waiting on Author
2025-03-03 14:54:57 Vitaly Davydov (vitprof) Changed authors to Vitaly Davydov (vitprof)
2025-03-03 14:53:27 Vitaly Davydov (vitprof) Attached mail thread 1d12d2-67235980-35-19a406a0@63439497
2025-03-03 14:53:27 Vitaly Davydov (vitprof) Created patch record
Edit