pgsql: Add defensive "split_only_page" nbtree assertion.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add defensive "split_only_page" nbtree assertion.
Date: 2020-04-14 04:11:36
Message-ID: E1jOCvA-0004On-6Q@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add defensive "split_only_page" nbtree assertion.

Clearly it's not okay for nbtree to split a page that is the only page
on its level, and then find that it has to split the parent one level up
in turn. There is simply no code to handle the split_only_page case in
the _bt_insertonpg() "newitem won't fit" branch (only the "newitem fits"
branch handles split_only_page). Add a defensive assertion that will
fail if a split_only_page call to _bt_insertonpg() somehow ends up
splitting the target/parent page.

I (pgeoghegan) believe that we don't need split_only_page handling for
the "newitem won't fit" branch because anybody calling _bt_insertonpg()
like this would have to hold a lock on the same one and only child page.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f762b2feba276a627585cb7e834fb7a1bf4c549d

Modified Files
--------------
src/backend/access/nbtree/nbtinsert.c | 2 ++
1 file changed, 2 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2020-04-14 04:12:29 pgsql: Repair last commit's new wait_for_catchup() call.
Previous Message Amit Kapila 2020-04-14 02:50:22 pgsql: Comments and doc fixes for commit 40d964ec99.