From edc211424326ffd63933c8e20d5614dc39ce2566 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 16 Nov 2010 11:02:11 +0200 Subject: The GiST scan algorithm uses LSNs to detect concurrent pages splits, but temporary indexes are not WAL-logged. We used a constant LSN for temporary indexes, on the assumption that we don't need to worry about concurrent page splits in temporary indexes because they're only visible to the current session. But that assumption is wrong, it's possible to insert rows and split pages in the same session, while a scan is in progress. For example, by opening a cursor and fetching some rows, and INSERTing new rows before fetching some more. Fix by generating fake increasing LSNs, used in place of real LSNs in temporary GiST indexes. --- src/backend/access/gist/gistvacuum.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/backend/access/gist/gistvacuum.c') diff --git a/src/backend/access/gist/gistvacuum.c b/src/backend/access/gist/gistvacuum.c index 5f5060280dd..b941e0a4a08 100644 --- a/src/backend/access/gist/gistvacuum.c +++ b/src/backend/access/gist/gistvacuum.c @@ -133,7 +133,7 @@ gistDeleteSubtree(GistVacuum *gv, BlockNumber blkno) PageSetTLI(page, ThisTimeLineID); } else - PageSetLSN(page, XLogRecPtrForTemp); + PageSetLSN(page, GetXLogRecPtrForTemp()); END_CRIT_SECTION(); @@ -252,7 +252,7 @@ vacuumSplitPage(GistVacuum *gv, Page tempPage, Buffer buffer, IndexTuple *addon, else { for (ptr = dist; ptr; ptr = ptr->next) - PageSetLSN(BufferGetPage(ptr->buffer), XLogRecPtrForTemp); + PageSetLSN(BufferGetPage(ptr->buffer), GetXLogRecPtrForTemp()); } for (ptr = dist; ptr; ptr = ptr->next) @@ -466,7 +466,7 @@ gistVacuumUpdate(GistVacuum *gv, BlockNumber blkno, bool needunion) pfree(rdata); } else - PageSetLSN(page, XLogRecPtrForTemp); + PageSetLSN(page, GetXLogRecPtrForTemp()); } END_CRIT_SECTION(); @@ -789,7 +789,7 @@ gistbulkdelete(PG_FUNCTION_ARGS) pfree(rdata); } else - PageSetLSN(page, XLogRecPtrForTemp); + PageSetLSN(page, GetXLogRecPtrForTemp()); END_CRIT_SECTION(); } -- cgit v1.2.3