Test-left-jumps-2.patch
text/x-patch
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/access/gist/gistbuild.c | 3 | 0 |
| src/backend/access/gist/gist.c | 16 | 0 |
| src/backend/access/gist/gistvacuum.c | 5 | 0 |
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index 3f52b8f4dc..cad4a2a46e 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -1187,6 +1187,8 @@ gistinserttuple(GISTInsertState *state, GISTInsertStack *stack,
InvalidBuffer, InvalidBuffer, false, false);
}
+static bool HACK = false;
+
/* ----------------
* An extended workhorse version of gistinserttuple(). This version allows
* inserting multiple tuples, or replacing a single tuple with multiple tuples.
@@ -1230,6 +1232,14 @@ gistinserttuples(GISTInsertState *state, GISTInsertStack *stack,
CheckForSerializableConflictIn(state->r, NULL, stack->buffer);
/* Insert the tuple(s) to the page, splitting the page if necessary */
+ if (BufferIsValid(leftchild) && HACK)
+ {
+ /* skip actually inserting */
+ splitinfo = NULL;
+ is_split = false;
+ }
+ else
+ {
is_split = gistplacetopage(state->r, state->freespace, giststate,
stack->buffer,
tuples, ntup,
@@ -1238,6 +1248,7 @@ gistinserttuples(GISTInsertState *state, GISTInsertStack *stack,
&splitinfo,
true,
state->heapRel);
+ }
/*
* Before recursing up in case the page was split, release locks on the
@@ -1256,7 +1267,12 @@ gistinserttuples(GISTInsertState *state, GISTInsertStack *stack,
* didn't have to split, release it ourselves.
*/
if (splitinfo)
+ {
+ if (random() % 2 == 0)
+ HACK = true;
gistfinishsplit(state, stack, giststate, splitinfo, unlockbuf);
+ HACK = false;
+ }
else if (unlockbuf)
LockBuffer(stack->buffer, GIST_UNLOCK);
diff --git a/src/backend/access/gist/gistbuild.c b/src/backend/access/gist/gistbuild.c
index bd142a3560..fdfc54b009 100644
--- a/src/backend/access/gist/gistbuild.c
+++ b/src/backend/access/gist/gistbuild.c
@@ -201,6 +201,9 @@ gistbuild(Relation heap, Relation index, IndexInfo *indexInfo)
buildstate.indtuples = 0;
buildstate.indtuplesSize = 0;
+ for (int i = 0; i < 100; i++)
+ ReleaseBuffer(ReadBuffer(index, P_NEW));
+
/*
* Do the heap scan.
*/
diff --git a/src/backend/access/gist/gistvacuum.c b/src/backend/access/gist/gistvacuum.c
index 1cbcb038f7..c306621e1e 100644
--- a/src/backend/access/gist/gistvacuum.c
+++ b/src/backend/access/gist/gistvacuum.c
@@ -254,6 +254,11 @@ restart:
(opaque->rightlink != InvalidBlockNumber) &&
(opaque->rightlink < orig_blkno))
{
+ if (GistFollowRight(page))
+ elog(LOG, "RESCAN %u->%u TRIGGERED BY FollowRight", blkno, opaque->rightlink);
+ if (vstate->startNSN < GistPageGetNSN(page))
+ elog(LOG,"RESCAN %u->%u TRIGGERED BY NSN", blkno, opaque->rightlink);
+
recurse_to = opaque->rightlink;
}