Re: Is this a problem in GenericXLogFinish()?

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Jeff Davis <pgsql(at)j-davis(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Is this a problem in GenericXLogFinish()?
Date: 2023-09-25 10:04:41
Message-ID: 25104133-7df8-cae3-b9a2-1c0aaa1c094a@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2023-09-25 10:11:41 Fix a wrong comment in setrefs.c
Previous Message Pavel Borisov 2023-09-25 09:58:02 Re: Index range search optimization