Kyotaro Horiguchi <horikyota....@gmail.com> wrote:

> At Mon, 11 Nov 2019 10:03:14 +0100, Antonin Houska <a...@cybertec.at> wrote 
> in 
> > Michael Paquier <mich...@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


Reply via email to