fix special case during recovery for hot_standby=off

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: fix special case during recovery for hot_standby=off
Date: 2026-11-06 23:17:48
Message-ID: 62b070d14df4d9d5f44cb8da6f15546c30259053.camel@j-davis.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

In xact_redo_commit(), the standbyState != STANDBY_DISABLED case uses
TransactionIdAsyncCommitTree() on the grounds that we can't let hint
bits be set for transactions prior to minRecoveryPoint. Based on that
reasoning, the STANDBY_DISABLED case doesn't need to worry, because it
won't be setting hint bits.

But hint bits aren't the only problem: we also can't let the CLOG
status go to disk prior to minRecoveryPoint, because a PITR to just
before the transaction committed could still see it as committed. That
has nothing to do with whether hot standby is enabled or not, so the
STANDBY_DISABLED case is wrong, and it also must use the async
protocol.

The cleanest fix would be to lift TransactionIdAsyncCommitTree() out of
the branch, placing it prior to RecordKnownAssignedTransactionIds() on
the !STANDBY_DISABLED case. But the comment above
RecordKnownAssignedTransactionIds() is especially scary, so out of an
abundance of caution I just replaced the call site for the
STANDBY_DISABLED case. That seems wise for the back branches, and we
can get rid of the second call site in master in a separate commit.

Patch attached.

Regards,
Jeff Davis

Attachment Content-Type Size
v1-0001-Recovery-ensure-CLOG-updates-wait-for-minRecovery.patch text/x-patch 2.3 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-11-06 23:20:31 Re: [PG19] pg_upgrade --check passes, then the upgrade fails
Previous Message Michael Paquier 2026-11-06 23:10:06 Re: [PG19] pg_dump marks extended statistics of pre-v15 partitioned tables as non-inherited