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-25T10:04:41Z
Lists: pgsql-hackers
On 22/09/2023 23:52, Jeff Davis wrote:
>
> src/backend/transam/README says:
>
> ...
> 4. Mark the shared buffer(s) as dirty with MarkBufferDirty(). (This
> must happen before the WAL record is inserted; see notes in
> SyncOneBuffer().)
> ...
>
> But GenericXLogFinish() does this:
>
> ...
> /* Insert xlog record */
> lsn = XLogInsert(RM_GENERIC_ID, 0);
>
> /* Set LSN and mark buffers dirty */
> for (i = 0; i < MAX_GENERIC_XLOG_PAGES; i++)
> {
> PageData *pageData = &state->pages[i];
>
> if (BufferIsInvalid(pageData->buffer))
> continue;
> PageSetLSN(BufferGetPage(pageData->buffer), lsn);
> MarkBufferDirty(pageData->buffer);
> }
> END_CRIT_SECTION();
>
> Am I missing something or is that a problem?
Yes, that's a problem.
I wish we had an assertion for that. XLogInsert() could assert that the
page is already marked dirty, for example.
--
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