Re: Is this a problem in GenericXLogFinish()?
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Jeff Davis <pgsql@j-davis.com>, pgsql-hackers@postgresql.org
Date: 2023-09-26T21:14:26Z
Lists: pgsql-hackers
On 26/09/2023 22:32, Jeff Davis wrote: > On Mon, 2023-09-25 at 13:04 +0300, Heikki Linnakangas wrote: >> Yes, that's a problem. > > Patch attached. I rearranged the code a bit to follow the expected > pattern of: write, mark dirty, WAL, set LSN. I think computing the > deltas could also be moved earlier, outside of the critical section, > but I'm not sure that would be useful. Looks correct. You now loop through all the block IDs three times, however. I wonder if that is measurably slower, but even if it's not, was there a reason you wanted to move the XLogRegisterBuffer() calls to a separate loop? > Do you have a suggestion for any kind of test addition, or should we > just review carefully? > >> I wish we had an assertion for that. XLogInsert() could assert that >> the page is already marked dirty, for example. > > Unfortunately that's not always the case, e.g. log_newpage_range(). Hmm, I'm sure there are exceptions but log_newpage_range() actually seems to be doing the right thing; it calls MarkBufferDirty() before XLogInsert(). It only calls it after XLogRegisterBuffer() though, and I concur that XLogRegisterBuffer() would be the logical place for the assertion. We could tighten this up, require that you call MarkBufferDirty() before XLogRegisterBuffer(), and fix all the callers. -- Heikki Linnakangas Neon (https://neon.tech)
Commits
-
Fix inconsistency with replay of hash squeeze record for clean buffers
- f56a9def71bb 17.0 landed
-
Set LSN for wbuf in _hash_freeovflpage() iff wbuf is modified.
- aa5edbe379d6 17.0 landed
-
Fix an uninitialized access in hash_xlog_squeeze_page().
- f66fcc5cd616 17.0 landed
-
Use REGBUF_NO_CHANGE at one more place in the hash index.
- 861f86beea1c 17.0 landed
-
Assert that buffers are marked dirty before XLogRegisterBuffer().
- 00d7fb5e2e39 17.0 landed
-
Fix bug in GenericXLogFinish().
- 04f0baa85865 11.22 landed
- 6dbd01b9fdad 12.17 landed
- 469d367bee2f 13.13 landed
- 6615bb95af2d 14.10 landed
- b9bb02620d4b 15.5 landed
- b8963e8a2854 16.1 landed
- ef74c7197c04 17.0 landed
-
Improve hash index bucket split behavior.
- 6d46f4783efe 10.0 cited