Re: datfrozenxid > relfrozenxid w/ crash before XLOG_HEAP_INPLACE
Noah Misch <noah@leadboat.com>
From: Noah Misch <noah@leadboat.com>
To: pgsql-hackers@postgresql.org
Date: 2025-04-13T20:37:58Z
Lists: pgsql-hackers
Attachments
- inplace280-comment-delay-v1.patch (text/plain) patch v1
On Sun, Apr 06, 2025 at 11:00:54AM -0700, Noah Misch wrote: > I pushed that as commit 8e7e672 (2024-10-25). I now think DELAY_CHKPT_START > is superfluous here, per this proc.h comment: > > * (In the > * extremely common case where the data being modified is in shared buffers > * and we acquire an exclusive content lock on the relevant buffers before > * writing WAL, this mechanism is not needed, because phase 2 will block > * until we release the content lock and then flush the modified data to > * disk.) > > heap_inplace_update_and_unlock() meets those conditions. Its closest > precedent is XLogSaveBufferForHint(), which does need DELAY_CHKPT_START due to > having only BUFFER_LOCK_SHARED. True so far, but ... > heap_inplace_update_and_unlock() has > BUFFER_LOCK_EXCLUSIVE, so it doesn't need DELAY_CHKPT_START. ... not so, because we've not yet done MarkBufferDirty(). transam/README cites SyncOneBuffer(), which says: * Check whether buffer needs writing. * * We can make this check without taking the buffer content lock so long * as we mark pages dirty in access methods *before* logging changes with * XLogInsert(): if someone marks the buffer dirty just after our check we * don't worry because our checkpoint.redo points before log record for * upcoming changes and so we are not required to write such dirty buffer. The attached patch updates the aforementioned proc.h comment and the heap_inplace_update_and_unlock() comment that my last message proposed.
Commits
-
WAL-log inplace update before revealing it to other sessions.
- e4b1986b9899 14.21 landed
- 720e9304fa0d 16.12 landed
- 20a48c156d64 15.16 landed
- d3e5d8950448 17.8 landed
- e30d0d8adf53 12.21 landed
- acf49584e216 14.14 landed
- 1e74e31f3c93 13.17 landed
- 659903f8e792 16.5 landed
- 431e05181e41 15.9 landed
- bfd5c6e279c8 17.1 landed
- 8e7e672cdaa6 18.0 landed
-
Comment on need to MarkBufferDirty() if omitting DELAY_CHKPT_START.
- 818013665259 18.0 landed