git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6d9ee03)
Bgwriter should PANIC if it runs out of memory for pending-fsyncs
2005年5月28日 17:21:32 +0000 (17:21 +0000)
2005年5月28日 17:21:32 +0000 (17:21 +0000)
hash table. This is a pretty unlikely scenario, since the table
should be tiny, but we can't guarantee continued correct operation
if it does occur. Spotted by Qingqing Zhou.


diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c
index 09775bd32ad61168c850af55a14ebb6bdf41140d..0cd694ef52989c6b1ac1b6ddbb51e35ba967bfc3 100644 (file)
--- a/src/backend/postmaster/bgwriter.c
+++ b/src/backend/postmaster/bgwriter.c
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.15 2005年03月04日 20:21:06 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.16 2005年05月28日 17:21:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -616,7 +616,7 @@ ForwardFsyncRequest(RelFileNode rnode, BlockNumber segno)
*
* This is exported because it must be called during CreateCheckPoint;
* we have to be sure we have accepted all pending requests *after* we
- * establish the checkpoint redo pointer. Since CreateCheckPoint
+ * establish the checkpoint REDO pointer. Since CreateCheckPoint
* sometimes runs in non-bgwriter processes, do nothing if not bgwriter.
*/
void
@@ -629,6 +629,15 @@ AbsorbFsyncRequests(void)
if (!am_bg_writer)
return;
+ /*
+ * We have to PANIC if we fail to absorb all the pending requests
+ * (eg, because our hashtable runs out of memory). This is because
+ * the system cannot run safely if we are unable to fsync what we
+ * have been told to fsync. Fortunately, the hashtable is so small
+ * that the problem is quite unlikely to arise in practice.
+ */
+ START_CRIT_SECTION();
+
/*
* We try to avoid holding the lock for a long time by copying the
* request array.
@@ -647,6 +656,9 @@ AbsorbFsyncRequests(void)
for (request = requests; n > 0; request++, n--)
RememberFsyncRequest(request->rnode, request->segno);
+
if (requests)
pfree(requests);
+
+ END_CRIT_SECTION();
}
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /