aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/buffer/freelist.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-08-21 14:43:00 -0400
committerRobert Haas <rhaas@postgresql.org>2017-08-21 14:17:39 -0400
commit79ccd7cbd5ca44bee0191d12e9e65abf702899e7 (patch)
tree61870b5ef1e67989c29ab070c11378e8522330c9 /src/backend/storage/buffer/freelist.c
parent66ed3829df959adb47f71d7c903ac59f0670f3e1 (diff)
downloadpostgresql-79ccd7cbd5ca44bee0191d12e9e65abf702899e7.tar.gz
postgresql-79ccd7cbd5ca44bee0191d12e9e65abf702899e7.zip
pg_prewarm: Add automatic prewarm feature.
Periodically while the server is running, and at shutdown, write out a list of blocks in shared buffers. When the server reaches consistency -- unfortunatey, we can't do it before that point without breaking things -- reload those blocks into any still-unused shared buffers. Mithun Cy and Robert Haas, reviewed and tested by Beena Emerson, Amit Kapila, Jim Nasby, and Rafia Sabih. Discussion: http://postgr.es/m/CAD__OugubOs1Vy7kgF6xTjmEqTR4CrGAv8w+ZbaY_+MZeitukw@mail.gmail.com
Diffstat (limited to 'src/backend/storage/buffer/freelist.c')
-rw-r--r--src/backend/storage/buffer/freelist.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c
index 9d8ae6ae8e1..f033323cfff 100644
--- a/src/backend/storage/buffer/freelist.c
+++ b/src/backend/storage/buffer/freelist.c
@@ -169,6 +169,23 @@ ClockSweepTick(void)
}
/*
+ * have_free_buffer -- a lockless check to see if there is a free buffer in
+ * buffer pool.
+ *
+ * If the result is true that will become stale once free buffers are moved out
+ * by other operations, so the caller who strictly want to use a free buffer
+ * should not call this.
+ */
+bool
+have_free_buffer()
+{
+ if (StrategyControl->firstFreeBuffer >= 0)
+ return true;
+ else
+ return false;
+}
+
+/*
* StrategyGetBuffer
*
* Called by the bufmgr to get the next candidate buffer to use in