| 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: | 4CE1A5FF.8000500@enterprisedb.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| 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
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 | Content-Type | Size |
|---|---|---|
| tempgist.sql | text/x-sql | 1.3 KB |
| fix-temp-gist-1.patch | text/x-diff | 3.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Fetter | 2010-11-15 22:11:24 | BUG #5754: CTE optimization fails to account for side effects |
| Previous Message | Tom Lane | 2010-11-15 17:24:26 | Re: BUG #5748: Invalid oidvector data during binary recv |