Re: Hash Indexes
Mithun Cy <mithun.cy@enterprisedb.com>
From: Mithun Cy <mithun.cy@enterprisedb.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2016-06-24T09:08:34Z
Lists: pgsql-hackers
On Thu, Jun 16, 2016 at 12:58 PM, Amit Kapila <amit.kapila16@gmail.com>
wrote:
I have a question regarding code changes in *_hash_first*.
+ /*
+ * Conditionally get the lock on primary bucket page for search
while
+ * holding lock on meta page. If we have to wait, then release the
meta
+ * page lock and retry it in a hard way.
+ */
+ bucket = _hash_hashkey2bucket(hashkey,
+
metap->hashm_maxbucket,
+
metap->hashm_highmask,
+
metap->hashm_lowmask);
+
+ blkno = BUCKET_TO_BLKNO(metap, bucket);
+
+ /* Fetch the primary bucket page for the bucket */
+ buf = ReadBuffer(rel, blkno);
+ if (!ConditionalLockBufferShared(buf))
Here we try to take lock on bucket page but I think if successful we do not
recheck whether any split happened before taking lock. Is this not
necessary now?
Also below "if" is always true as we enter here only when outer "if
(retry)" is true.
+ if (retry)
+ {
+ if (oldblkno == blkno)
+ break;
+ _hash_relbuf(rel, buf);
+ }
--
Thanks and Regards
Mithun C Y
EnterpriseDB: http://www.enterprisedb.com
Commits
-
Remove _hash_wrtbuf() in favor of calling MarkBufferDirty().
- 25216c989384 10.0 landed
-
Fix race introduced by 6d46f4783efe457f74816a75173eb23ed8930020.
- 2f4193c3509a 10.0 cited
-
Improve hash index bucket split behavior.
- 6d46f4783efe 10.0 landed
-
Reduce pinning and buffer content locking for btree scans.
- 2ed5b87f96d4 9.5.0 cited