diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-12-05 11:43:37 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-12-05 11:43:37 -0500 |
commit | 2f4193c3509a822c55cc0eae77e7788806d9b022 (patch) | |
tree | 16474cfff7f512987de3e3cf6745b443d08595bf /src | |
parent | 0e50af245397c9bf3e7b02c0958be599de838fac (diff) | |
download | postgresql-2f4193c3509a822c55cc0eae77e7788806d9b022.tar.gz postgresql-2f4193c3509a822c55cc0eae77e7788806d9b022.zip |
Fix race introduced by 6d46f4783efe457f74816a75173eb23ed8930020.
It's possible for the metapage contents to change after we release
the lock, so we must read them before releasing the lock.
Amit Kapila. Submitted in response to a trouble report from
Andreas Seltenreich, though it is not certain this fixes the
problem.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/hash/hashpage.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c index 74ffa9d161f..44332e72ec6 100644 --- a/src/backend/access/hash/hashpage.c +++ b/src/backend/access/hash/hashpage.c @@ -653,13 +653,21 @@ restart_expand: */ if (H_NEEDS_SPLIT_CLEANUP(oopaque)) { + /* + * Copy bucket mapping info now; refer to the comment in code below + * where we copy this information before calling _hash_splitbucket + * to see why this is okay. + */ + maxbucket = metap->hashm_maxbucket; + highmask = metap->hashm_highmask; + lowmask = metap->hashm_lowmask; + /* Release the metapage lock. */ _hash_chgbufaccess(rel, metabuf, HASH_READ, HASH_NOLOCK); hashbucketcleanup(rel, old_bucket, buf_oblkno, start_oblkno, NULL, - metap->hashm_maxbucket, metap->hashm_highmask, - metap->hashm_lowmask, NULL, - NULL, true, NULL, NULL); + maxbucket, highmask, lowmask, NULL, NULL, true, + NULL, NULL); _hash_dropbuf(rel, buf_oblkno); |