Remove unnecessary segment number calculation after wal_removed invalidation of replication slots
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t49450psql -h localhost -U postgresBuilt from patchset v1 (message #1), October 06, 2026 at 07:47 AM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t49450_1 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t49450_1 && git checkout t49450_1Patchset v1 (message #1) is on t49450_1
Hi,
It looks like there's an unnecessary segment number calculation after
InvalidateObsoleteReplicationSlots in CreateCheckPoint and
CreateRestartPoint. Since none of RedoRecPtr, _logSegNo and
wal_segment_size are changed by the slot invalidation code [1]Assertions like the following won't fail with make check-world proving InvalidateObsoleteReplicationSlots doesn't change them at all., the
recalculation of
_logSegNo with XLByteToSeg seems unnecessary.
I've attached a patch to fix this.
[1]: Assertions like the following won't fail with make check-world proving InvalidateObsoleteReplicationSlots doesn't change them at all.
proving InvalidateObsoleteReplicationSlots doesn't change them at all.
XLByteToSeg(RedoRecPtr, _logSegNo, wal_segment_size);
KeepLogSeg(recptr, &_logSegNo);
+ _logSegNo_saved = _logSegNo;
+ RedoRecPtr_saved = RedoRecPtr;
if (InvalidateObsoleteReplicationSlots(RS_INVAL_WAL_REMOVED,
_logSegNo, InvalidOid,
InvalidTransactionId))
{
+ Assert(_logSegNo_saved == _logSegNo);
+ Assert(RedoRecPtr_saved == RedoRecPtr);
--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com