summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2000-10-22 20:33:22 +0000
committerTom Lane2000-10-22 20:33:22 +0000
commit67797231263701553ce0e11c34e473efe8c10096 (patch)
tree3a4cf40c1b7b2d2dad5dc1e93a046cc788d5a304
parent6dee4ac84ce6382ce55a51ab519a1e37e00738f1 (diff)
Back-patch fix for bogus clearing of BufferDirtiedByMe.
-rw-r--r--src/backend/storage/buffer/bufmgr.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index 3f659ada461..8390feeaa42 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.81.2.2 2000/10/04 07:50:00 inoue Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.81.2.3 2000/10/22 20:33:22 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1656,7 +1656,6 @@ recheck:
}
/* Now we can do what we came for */
buf->flags &= ~(BM_DIRTY | BM_JUST_DIRTIED);
- ClearBufferDirtiedByMe(i, buf);
/*
* Release any refcount we may have.
@@ -1680,7 +1679,23 @@ recheck:
*/
BufTableDelete(buf);
}
+
+ /*
+ * Also check to see if BufferDirtiedByMe info for this buffer
+ * refers to the target relation, and clear it if so. This is
+ * independent of whether the current contents of the buffer
+ * belong to the target relation!
+ *
+ * NOTE: we have no way to clear BufferDirtiedByMe info in other
+ * backends, but hopefully there are none with that bit set for
+ * this rel, since we hold exclusive lock on this rel.
+ */
+ if (BufferTagLastDirtied[i - 1].relId.relId == relid &&
+ (BufferTagLastDirtied[i - 1].relId.dbId == MyDatabaseId ||
+ BufferTagLastDirtied[i - 1].relId.dbId == (Oid) NULL))
+ BufferDirtiedByMe[i - 1] = false;
}
+
SpinRelease(BufMgrLock);
}
@@ -1726,7 +1741,6 @@ recheck:
}
/* Now we can do what we came for */
buf->flags &= ~(BM_DIRTY | BM_JUST_DIRTIED);
- ClearBufferDirtiedByMe(i, buf);
/*
* The thing should be free, if caller has checked that no
@@ -1738,7 +1752,20 @@ recheck:
*/
BufTableDelete(buf);
}
+
+ /*
+ * Also check to see if BufferDirtiedByMe info for this buffer
+ * refers to the target database, and clear it if so. This is
+ * independent of whether the current contents of the buffer
+ * belong to the target database!
+ *
+ * (Actually, this is probably unnecessary, since I shouldn't have
+ * ever dirtied pages of the target database, but...)
+ */
+ if (BufferTagLastDirtied[i - 1].relId.dbId == dbid)
+ BufferDirtiedByMe[i - 1] = false;
}
+
SpinRelease(BufMgrLock);
}