summaryrefslogtreecommitdiff
path: root/src/backend/postmaster/checkpointer.c
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2012-06-01 09:24:53 +0100
committerSimon Riggs <simon@2ndQuadrant.com>2012-06-01 09:24:53 +0100
commit055c352abbf764a08496e94054137da9e26dac04 (patch)
tree498c69122a13e44fc59a3b913bea47259a291a30 /src/backend/postmaster/checkpointer.c
parenta297d64d9223f6bd9c495ff5726a3c99080c2a4a (diff)
After any checkpoint, close all smgr files handles in bgwriter
Diffstat (limited to 'src/backend/postmaster/checkpointer.c')
-rw-r--r--src/backend/postmaster/checkpointer.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index aa3df373247..6aeade92e6a 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -1346,3 +1346,28 @@ UpdateSharedMemoryConfig(void)
elog(DEBUG2, "checkpointer updated shared memory configuration values");
}
+
+/*
+ * FirstCallSinceLastCheckpoint allows a process to take an action once
+ * per checkpoint cycle by asynchronously checking for checkpoint completion.
+ */
+bool
+FirstCallSinceLastCheckpoint(void)
+{
+ /* use volatile pointer to prevent code rearrangement */
+ volatile CheckpointerShmemStruct *cps = CheckpointerShmem;
+ static int ckpt_done = 0;
+ int new_done;
+ bool FirstCall = false;
+
+ SpinLockAcquire(&cps->ckpt_lck);
+ new_done = cps->ckpt_done;
+ SpinLockRelease(&cps->ckpt_lck);
+
+ if (new_done != ckpt_done)
+ FirstCall = true;
+
+ ckpt_done = new_done;
+
+ return FirstCall;
+}