summaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gist.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-11-16 11:02:11 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-11-16 11:38:32 +0200
commitf06829992556f54a82edf1372dadc1e2f4b51935 (patch)
tree22376411a24c56b14a2b3f30aae67b8b562889fc /src/backend/access/gist/gist.c
parent6a93cb689a03aaaa04bbc446778de9029efad56d (diff)
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.
Diffstat (limited to 'src/backend/access/gist/gist.c')
-rw-r--r--src/backend/access/gist/gist.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index 26f3ddbf853..1cea03d73a6 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -20,8 +20,6 @@
#include "miscadmin.h"
#include "utils/memutils.h"
-const XLogRecPtr XLogRecPtrForTemp = {1, 1};
-
/* Working state for gistbuild and its callback */
typedef struct
{
@@ -130,7 +128,7 @@ gistbuild(PG_FUNCTION_ARGS)
PageSetTLI(page, ThisTimeLineID);
}
else
- PageSetLSN(page, XLogRecPtrForTemp);
+ PageSetLSN(page, GetXLogRecPtrForTemp());
UnlockReleaseBuffer(buffer);
@@ -421,7 +419,7 @@ gistplacetopage(GISTInsertState *state, GISTSTATE *giststate)
{
for (ptr = dist; ptr; ptr = ptr->next)
{
- PageSetLSN(ptr->page, XLogRecPtrForTemp);
+ PageSetLSN(ptr->page, GetXLogRecPtrForTemp());
}
}
@@ -489,7 +487,7 @@ gistplacetopage(GISTInsertState *state, GISTSTATE *giststate)
PageSetTLI(state->stack->page, ThisTimeLineID);
}
else
- PageSetLSN(state->stack->page, XLogRecPtrForTemp);
+ PageSetLSN(state->stack->page, GetXLogRecPtrForTemp());
if (state->stack->blkno == GIST_ROOT_BLKNO)
state->needInsertComplete = false;
@@ -1025,7 +1023,7 @@ gistnewroot(Relation r, Buffer buffer, IndexTuple *itup, int len, ItemPointer ke
PageSetTLI(page, ThisTimeLineID);
}
else
- PageSetLSN(page, XLogRecPtrForTemp);
+ PageSetLSN(page, GetXLogRecPtrForTemp());
END_CRIT_SECTION();
}