Commit 6a4fe112 authored by Robert Haas's avatar Robert Haas

Fix more hash index bugs around marking buffers dirty.

In _hash_freeovflpage(), if we're freeing the overflow page that
immediate follows the page to which tuples are being moved (the
confusingly-named "write buffer"), don't forget to mark that
page dirty after updating its hasho_nextblkno.

In _hash_squeezebucket(), it's not necessary to mark the primary
bucket page dirty if there are no overflow pages, because there's
nothing to squeeze in that case.

Amit Kapila, with help from Kuntal Ghosh and Dilip Kumar, after
an initial trouble report by Jeff Janes.
parent 25216c98
...@@ -452,6 +452,11 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf, Buffer wbuf, ...@@ -452,6 +452,11 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf, Buffer wbuf,
MarkBufferDirty(prevbuf); MarkBufferDirty(prevbuf);
_hash_relbuf(rel, prevbuf); _hash_relbuf(rel, prevbuf);
} }
else
{
/* ensure to mark prevbuf as dirty */
wbuf_dirty = true;
}
} }
/* write and unlock the write buffer */ /* write and unlock the write buffer */
...@@ -643,7 +648,7 @@ _hash_squeezebucket(Relation rel, ...@@ -643,7 +648,7 @@ _hash_squeezebucket(Relation rel,
*/ */
if (!BlockNumberIsValid(wopaque->hasho_nextblkno)) if (!BlockNumberIsValid(wopaque->hasho_nextblkno))
{ {
_hash_chgbufaccess(rel, wbuf, HASH_WRITE, HASH_NOLOCK); _hash_chgbufaccess(rel, wbuf, HASH_READ, HASH_NOLOCK);
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment