aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2011-09-27 08:24:18 -0400
committerRobert Haas <rhaas@postgresql.org>2011-09-27 08:24:18 -0400
commit624f155ffa93d1af4fb9d91fd5c0eb05da1e9e54 (patch)
tree0cf6d5fe8e63fb54f1d972a343b9cb3b52f7004e /src
parent269c5dd2f46e3490da05d5dd5dad07828df281d9 (diff)
downloadpostgresql-624f155ffa93d1af4fb9d91fd5c0eb05da1e9e54.tar.gz
postgresql-624f155ffa93d1af4fb9d91fd5c0eb05da1e9e54.zip
heap_update() must recheck tuple after unlocking and relocking buffer.
Bug found by Alvaro Herrera, fix suggested by Heikki Linnakangas and reviewed by Tom Lane.
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/heap/heapam.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 17950d482c1..b2d19016e76 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -2645,13 +2645,16 @@ l2:
* visible while we were busy locking the buffer, or during some subsequent
* window during which we had it unlocked, we'll have to unlock and
* re-lock, to avoid holding the buffer lock across an I/O. That's a bit
- * unfortunate, but hopefully shouldn't happen often.
+ * unfortunate, esepecially since we'll now have to recheck whether the
+ * tuple has been locked or updated under us, but hopefully it won't
+ * happen very often.
*/
if (vmbuffer == InvalidBuffer && PageIsAllVisible(page))
{
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
visibilitymap_pin(relation, block, &vmbuffer);
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
+ goto l2;
}
/*