RelationTruncate() must set DELAY_CHKPT_START.
authorThomas Munro <[email protected]>
Mon, 2 Dec 2024 20:27:05 +0000 (09:27 +1300)
committerThomas Munro <[email protected]>
Mon, 2 Dec 2024 21:13:49 +0000 (10:13 +1300)
commit1168acbca475d48f745b345f69389df11f2396aa
tree23f447f0d09fa1919420ad2b067ddbaffd6ee9f7
parente359cbb846788c584767288497beaa788a0f1b3e
RelationTruncate() must set DELAY_CHKPT_START.

Previously, it set only DELAY_CHKPT_COMPLETE. That was important,
because it meant that if the XLOG_SMGR_TRUNCATE record preceded a
XLOG_CHECKPOINT_ONLINE record in the WAL, then the truncation would also
happen on disk before the XLOG_CHECKPOINT_ONLINE record was
written.

However, it didn't guarantee that the sync request for the truncation
was processed before the XLOG_CHECKPOINT_ONLINE record was written. By
setting DELAY_CHKPT_START, we guarantee that if an XLOG_SMGR_TRUNCATE
record is written to WAL before the redo pointer of a concurrent
checkpoint, the sync request queued by that operation must be processed
by that checkpoint, rather than being left for the following one.

This is a refinement of commit 412ad7a5563.  Back-patch to all supported
releases, like that commit.

Author: Robert Haas <[email protected]>
Reported-by: Thomas Munro <[email protected]>
Discussion: https://postgr.es/m/CA%2BhUKG%2B-2rjGZC2kwqr2NMLBcEBp4uf59QT1advbWYF_uc%2B0Aw%40mail.gmail.com
src/backend/catalog/storage.c