summaryrefslogtreecommitdiff
path: root/src/backend/access/hash/hashinsert.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2016-12-16 09:29:21 -0500
committerRobert Haas <rhaas@postgresql.org>2016-12-16 09:37:28 -0500
commit25216c98938495fd741bf585dcbef45b3a9ffd40 (patch)
tree497485655e61a57e583af25151db581457885381 /src/backend/access/hash/hashinsert.c
parent4f5182e18d3ec7b84c24ceba2c436ea890c95e25 (diff)
downloadpostgresql-25216c98938495fd741bf585dcbef45b3a9ffd40.tar.gz
Remove _hash_wrtbuf() in favor of calling MarkBufferDirty().
The whole concept of _hash_wrtbuf() is that we need to know at the time we're releasing the buffer lock (and pin) whether we dirtied the buffer, but this is easy to get wrong. This patch actually fixes one non-obvious bug of that form: hashbucketcleanup forgot to signal _hash_squeezebucket, which gets the primary bucket page already locked, as to whether it had already dirtied the page. Calling MarkBufferDirty() at the places where we dirty the buffer is more intuitive and lets us simplify the code in various places as well. On top of all that, the ultimate goal here is to make hash indexes WAL-logged, and as the comments to _hash_wrtbuf() note, it should go away when that happens. Making it go away a little earlier than that seems like a good preparatory step. Report by Jeff Janes. Diagnosis by Amit Kapila, Kuntal Ghosh, and Dilip Kumar. Patch by me, after studying an alternative patch submitted by Amit Kapila. Discussion: http://postgr.es/m/CAA4eK1Kf6tOY0oVz_SEdngiNFkeXrA3xUSDPPORQvsWVPdKqnA@mail.gmail.com
Diffstat (limited to 'src/backend/access/hash/hashinsert.c')
-rw-r--r--src/backend/access/hash/hashinsert.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/access/hash/hashinsert.c b/src/backend/access/hash/hashinsert.c
index 572146a403..59c4213f9c 100644
--- a/src/backend/access/hash/hashinsert.c
+++ b/src/backend/access/hash/hashinsert.c
@@ -208,11 +208,12 @@ restart_insert:
(void) _hash_pgaddtup(rel, buf, itemsz, itup);
/*
- * write and release the modified page. if the page we modified was an
+ * dirty and release the modified page. if the page we modified was an
* overflow page, we also need to separately drop the pin we retained on
* the primary bucket page.
*/
- _hash_wrtbuf(rel, buf);
+ MarkBufferDirty(buf);
+ _hash_relbuf(rel, buf);
if (buf != bucket_buf)
_hash_dropbuf(rel, bucket_buf);