Replay of a commit timestamp truncation unlinks pg_commit_ts segments without advancing minRecoveryPoint, so recovery restarted with an earlier target (e.g. after a standby crash) fails commit timestamp lookups with "could not open file" ============================================================================================================================================================================================================================================= AI-generated bug report from the AI Annex Report ID: 01a1f7a7-751a-7f07-9d13-9a3240844f48 Filed: 2026-11-20 06:31:49 UTC Severity: 38/100 Blamed commit: 73c986adde5d73a5e2555da9b5c8facedb146dcd ## Summary On the primary, `TruncateCommitTs()` WAL-logs the `COMMIT_TS_TRUNCATE` record and then unlinks pg_commit_ts segments. On a standby, `commit_ts_redo()` replays that record by calling `AdvanceOldestCommitTsXid()` and `SimpleLruTruncate()` directly, without advancing minRecoveryPoint first. The segment removal is irreversible, but minRecoveryPoint can still point before the VACUUM that advanced datfrozenxid and caused the truncation. If the standby then crashes (or is stopped with `-m immediate`) and is restarted with a recovery target between minRecoveryPoint and the truncation, recovery accepts the target as consistent. The checkpoint it starts from still has the old oldestCommitTsXid, so lookups of XIDs in the removed segment are not short-circuited and fail: ERROR: could not open file "pg_commit_ts/0000": No such file or directory DETAIL: Could not access commit timestamp of transaction 665. The expected answer is the commit timestamp (the segment still existed at the target LSN), or at worst NULL. This is the same class as the reported replay paths for CLOG and multixact truncation and others (see Notes), but in commit_ts_redo(). It is a different path from the primary-side report about unlinking pg_commit_ts before the truncate record is flushed, and from the report about replayed commit timestamps being written without advancing minRecoveryPoint. ## Reproduction Two clusters on ports P and S. About 30000 XIDs are consumed with subtransactions so that the first pg_commit_ts segment (26208 XIDs) becomes truncatable. initdb -D pri -A trust cat >> pri/postgresql.conf <> sby/postgresql.conf <> sby/postgresql.conf <