Bug in concurrency control in temporary GiST indexes - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Bug in concurrency control in temporary GiST indexes
Date
Msg-id 4CE1A5FF.8000500@enterprisedb.com
Whole thread Raw
List pgsql-bugs
While hacking on the GiST insertion algorithm, I noticed a bug with
temporary GiST indexes. The scan algorithm uses LSNs to detect a
concurrent page split, but for a temporary index, we just use a constant
LSN on the assumption that there can't be anyone else modifying the
index concurrently. But that assumption is not true. While a temporary
index can't be modified by other backends, it's entirely possible to
insert new tuples to the index within the same backend while a scan is
in progress.

Here's a test case, using btree_gist. If you modify it to use a
non-temporary table, it works fine, but with a temporary table the 2nd
SELECT misses some rows, when new rows are inserted in the middle of the
scan.

Operations on temporary tables are not WAL-logged, so we don't have LSNs
to use, but we just need a monotonically increasing sequence of numbers
for this purpose. Attached patch provides a function to generate such
fake LSNs.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

Attachment

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #5748: Invalid oidvector data during binary recv
Next
From: "David Fetter"
Date:
Subject: BUG #5754: CTE optimization fails to account for side effects