Allow old WAL recycling during REPACK CONCURRENTLY

Álvaro Herrera <alvherre@kurilemu.de>

Commit: 45b02984e2fa9ee7bd83f7e58797b160baf0cc13
Author: Álvaro Herrera <alvherre@kurilemu.de>
Date: 2026-05-29T22:23:25Z
Allow old WAL recycling during REPACK CONCURRENTLY

During REPACK CONCURRENTLY, logical decoding keeps replication
slot.restart_lsn pinned behind the oldest running transaction, which is
often the long-lived REPACK transaction itself. As a result, old WAL
segments are retained longer than necessary.

This commit advances the replication slot each time WAL insertion
crosses a segment boundary, so obsolete WAL files can be recycled while
REPACK is still running.

Author: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Antonin Houska <ah@cybertec.at>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>

Discussion: https://postgr.es/m/TY4PR01MB17718B44164522D0798F8E898940A2@TY4PR01MB17718.jpnprd01.prod.outlook.com

Files

PathChange+/−
src/backend/commands/repack_worker.c modified +18 −2

Discussion