Assertion failure in _bt_pagedel (leafblkno == scanblkno) after interrupted VACUUM

Started by Iliia Khaprovabout 2 months ago4 messagesbugs
Jump to latest
#1Iliia Khaprov
i.khaprov@gmail.com

Hello,

We were doing some fuzzing with an oss-fuzz derivative
(github.com/stroppy-io/pg-fuzz). The usual crashes are ubsan-only
integer shifts. Yesterday it was a new thing - a cassert
in half-dead page processing (originally found on 17.10):

TRAP: failed Assert("leafblkno == scanblkno"), File: "nbtpage.c", Line:
1949

Note, unlike a similar report from 2024 on the same line, this one does
not need any concurrency.

A sweep was done across REL_16 to REL_19 and master heads:
master 5bd2e236e21b nbtpage.c:1959
REL_19_STABLE bb356f869fa5 nbtpage.c:1979
REL_18_STABLE ccffd34399f5 nbtpage.c:1949
REL_17_STABLE 0165f38d11ec nbtpage.c:1949
REL_16_STABLE 6f2f510845c5 nbtpage.c:1954

Stack trace, reproducer SQL and matrix summary attached. Reproduced on
master and REL_19 with the nbtree-leave-page-half-dead injection point.
The reproducer needs VACUUM (INDEX_CLEANUP ON).

I of course LLMed this and have a patch. LMK if it is of any interest.
Hope it was helpful,
Iliia

Attachments:

server-log-trap-excerpt.txttext/plain; charset=US-ASCII; name=server-log-trap-excerpt.txtDownload
matrix-summary.txttext/plain; charset=US-ASCII; name=matrix-summary.txtDownload
halfdead_rightsib.sqlapplication/sql; name=halfdead_rightsib.sqlDownload
halfdead_rightsib_guc.sqlapplication/sql; name=halfdead_rightsib_guc.sqlDownload
#2shihao zhong
zhong950419@gmail.com
In reply to: Iliia Khaprov (#1)
Re: Assertion failure in _bt_pagedel (leafblkno == scanblkno) after interrupted VACUUM

Hi Iliia,

Thanks, I can reproduce this on master with your script.

_bt_pagedel() builds no descent stack when the page it is given is
already half-dead. If the right sibling of that page is empty too, it
steps right and builds the stack there. The assertion insisted that this
only happens for the initial page. That stopped being true once an
interrupted VACUUM could leave the initial page half-dead.

Feels like the right way is to remove the assertion.

Thanks,
Shihao

#3Iliia Khaprov
i.khaprov@gmail.com
In reply to: shihao zhong (#2)
Re: Assertion failure in _bt_pagedel (leafblkno == scanblkno) after interrupted VACUUM

Thank you Shihao,

I will submit a patch.

Best regards,
Iliia

On Wed, Sep 30, 2026 at 7:00 AM shihao zhong <zhong950419@gmail.com> wrote:

Show quoted text

Hi Iliia,

Thanks, I can reproduce this on master with your script.

_bt_pagedel() builds no descent stack when the page it is given is
already half-dead. If the right sibling of that page is empty too, it
steps right and builds the stack there. The assertion insisted that this
only happens for the initial page. That stopped being true once an
interrupted VACUUM could leave the initial page half-dead.

Feels like the right way is to remove the assertion.

Thanks,
Shihao

In reply to: Iliia Khaprov (#1)
Re: Assertion failure in _bt_pagedel (leafblkno == scanblkno) after interrupted VACUUM

On Mon, Sep 28, 2026 at 3:31 PM Iliia Khaprov <i.khaprov@gmail.com> wrote:

We were doing some fuzzing with an oss-fuzz derivative
(github.com/stroppy-io/pg-fuzz). The usual crashes are ubsan-only
integer shifts. Yesterday it was a new thing - a cassert
in half-dead page processing (originally found on 17.10):

TRAP: failed Assert("leafblkno == scanblkno"), File: "nbtpage.c", Line: 1949

I pushed a fix for this just now.

Thanks for the report.

--
Peter Geoghegan