Skip site navigation (1) Skip section navigation (2)

Bug in concurrency control in temporary GiST indexes

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Cc: Teodor Sigaev <teodor(at)sigaev(dot)ru>, Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
Subject: Bug in concurrency control in temporary GiST indexes
Date: 2010-11-15 21:28:31
Message-ID: (view raw, whole thread or download thread mbox)
Lists: 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 

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

Attachment: tempgist.sql
Description: text/x-sql (1.3 KB)
Attachment: fix-temp-gist-1.patch
Description: text/x-diff (3.1 KB)

pgsql-bugs by date

Next:From: David FetterDate: 2010-11-15 22:11:24
Subject: BUG #5754: CTE optimization fails to account for side effects
Previous:From: Tom LaneDate: 2010-11-15 17:24:26
Subject: Re: BUG #5748: Invalid oidvector data during binary recv

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group