Page on disk has empty lp 1 * Insert into page lp 1 checkpoint START. Redo eventually starts here. ** Delete all rows on page. autovac truncate DropRelFileNodeBuffers - dirty page NOT written. lp 1 on disk still empty checkpoint completes crash smgrtruncate - Not reached
heap_xlog_delete reads page with empty lp 1 and the delete fails. The checkpoint can not have yet written * or ** before DropRelFileNodeBuffers invalidates either of those dirty page versions for this to repro. Even if we reach the truncate we don't fsync it till the next checkpoint. So on filesystems which delay metadata updates a crash can lose the truncate. Once we do the fsync(), for the truncate, the REDO read will return BLK_NOTFOUND and the DELETE REDO attempt will be skipped. WIthout the fsync() or crashing before the truncate, the delete redo depends on the most recent version of the page having been written by the checkpoint. Found during stress test and verified with pg_usleep's to test hypothesis. Is DropRelFileNodeBuffers purely for performance or would there be any correctness problems if not done.