From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com> |
Subject: | Re: lazy_scan_heap() forgets to mark buffer dirty when setting all frozen? |
Date: | 2019-04-08 06:15:11 |
Message-ID: | CAD21AoCWeLJGJCOLrQ1PHWPyfCTAkab1jMK+sJ=U2CVnqKzAwA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Apr 8, 2019 at 12:49 PM Andres Freund <andres(at)anarazel(dot)de> wrote:
>
> Hi,
>
> lazy_scan_heap() contains the following block:
>
> /*
> * If the all-visible page is turned out to be all-frozen but not
> * marked, we should so mark it. Note that all_frozen is only valid
> * if all_visible is true, so we must check both.
> */
> else if (all_visible_according_to_vm && all_visible && all_frozen &&
> !VM_ALL_FROZEN(onerel, blkno, &vmbuffer))
> {
> /*
> * We can pass InvalidTransactionId as the cutoff XID here,
> * because setting the all-frozen bit doesn't cause recovery
> * conflicts.
> */
> visibilitymap_set(onerel, blkno, buf, InvalidXLogRecPtr,
> vmbuffer, InvalidTransactionId,
> VISIBILITYMAP_ALL_FROZEN);
> }
>
> but I'm afraid that's not quite enough. As an earlier comment explains:
>
>
> * NB: If the heap page is all-visible but the VM bit is not set,
> * we don't need to dirty the heap page. However, if checksums
> * are enabled, we do need to make sure that the heap page is
> * dirtied before passing it to visibilitymap_set(), because it
> * may be logged. Given that this situation should only happen in
> * rare cases after a crash, it is not worth optimizing.
> */
> PageSetAllVisible(page);
> MarkBufferDirty(buf);
> visibilitymap_set(onerel, blkno, buf, InvalidXLogRecPtr,
> vmbuffer, visibility_cutoff_xid, flags);
>
> don't we need to do that here too?
Thank you for pointing out. I think that the same things are necessary
here. Otherwise does it lead the case that the visibility map page is
set while the heap page bit is cleared?
Regards,
--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2019-04-08 06:17:25 | Re: pg_rewind vs superuser |
Previous Message | Heikki Linnakangas | 2019-04-08 06:08:05 | Re: change password_encryption default to scram-sha-256? |