Re: MarkBufferDirtyHint() and LSN update - Mailing list pgsql-hackers

From Antonin Houska
Subject Re: MarkBufferDirtyHint() and LSN update
Date
Msg-id 57161.1573565236@antos
Whole thread Raw
In response to Re: MarkBufferDirtyHint() and LSN update  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
List pgsql-hackers
Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:

> At Mon, 11 Nov 2019 10:03:14 +0100, Antonin Houska <ah@cybertec.at> wrote in
> > Michael Paquier <michael@paquier.xyz> wrote:
> > > Does something like the attached patch make sense?  Reviews are
> > > welcome.
> >
> > This looks good to me.
>
> I have a qustion.
>
> The current code assumes that !BM_DIRTY means that the function is
> dirtying the page.  But if !BM_JUST_DIRTIED, the function actually is
> going to re-dirty the page even if BM_DIRTY.

It makes sense to me. I can imagine the following:

1. FlushBuffer() cleared BM_JUST_DIRTIED, wrote the page to disk but hasn't
yet cleared BM_DIRTY.

2. Another backend changed a hint bit in shared memory and called
MarkBufferDirtyHint().

Thus FlushBuffer() missed the current hint bit change, so we need to dirty the
page again.

> If this is correct, the trigger for stats update is not !BM_DIRTY but
> !BM_JUST_DIRTIED, or the fact that we passed the line of
> XLogSaveBufferForHint() could be the trigger, regardless whether the
> LSN is valid or not.

I agree.

--
Antonin Houska
Web: https://www.cybertec-postgresql.com



pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: [PATCH][BUG_FIX] Potential null pointer dereferencing.
Next
From: Daniel Gustafsson
Date:
Subject: Re: Option to dump foreign data in pg_dump