Re: BUG #17949: Adding an index introduces serialisation anomalies.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, artem(dot)anisimov(dot)255(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Teodor Sigaev <teodor(at)sigaev(dot)ru>
Subject: Re: BUG #17949: Adding an index introduces serialisation anomalies.
Date: 2026-07-19 19:53:48
Message-ID: CAH2-WzkNoTn3yXY0iGkSuavJ+sL8EROf+kitW+_2v2tJVWuKmA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Jun 27, 2023 at 11:18 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> I'll push these in a couple of days if there are no further comments.

I spotted an oversight in this fix: scans that use no scan keys (i.e.,
full index scans, or the first primscan used during a skip scan) will
go through _bt_endpoint, which lacks the _bt_first handling that you
added to the end of _bt_first (which will never be reached). You need
a second copy of the empty tree handling in _bt_endpoint.

Attached bug fix shows what I mean.

There's a second patch that adds an isolation test that would have
caught the original problem, as well as this still-overlooked
_bt_endpoint variant. When this fix went in we didn't have injection
points. Now we do, which makes testing these kinds of scenarios
straightforward.

--
Peter Geoghegan

Attachment Content-Type Size
v1-0001-Fix-race-in-SSI-interaction-with-empty-btrees.patch application/octet-stream 1.9 KB
v1-0002-Add-empty-nbtree-index-SSI-tests.patch application/octet-stream 8.2 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Guo 2026-07-20 02:33:23 Re: BUG #19553: Wrong results from nested LEFT JOINs over an empty subquery (regression since v16)
Previous Message Danimar Ribeiro 2026-07-19 16:20:36 Re: BUG #19424: Concurrent PQconnectdb() calls hang on Windows