summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/transam/xlog.c15
-rw-r--r--src/backend/storage/smgr/md.c14
2 files changed, 21 insertions, 8 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index c64febdb53d..8e8bdde7646 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8812,6 +8812,14 @@ CreateCheckPoint(int flags)
CheckpointStats.ckpt_start_t = GetCurrentTimestamp();
/*
+ * Let smgr prepare for checkpoint; this has to happen outside the
+ * critical section and before we determine the REDO pointer. Note that
+ * smgr must not do anything that'd have to be undone if we decide no
+ * checkpoint is needed.
+ */
+ smgrpreckpt();
+
+ /*
* Use a critical section to force system panic if we have trouble.
*/
START_CRIT_SECTION();
@@ -8825,13 +8833,6 @@ CreateCheckPoint(int flags)
LWLockRelease(ControlFileLock);
}
- /*
- * Let smgr prepare for checkpoint; this has to happen before we determine
- * the REDO pointer. Note that smgr must not do anything that'd have to
- * be undone if we decide no checkpoint is needed.
- */
- smgrpreckpt();
-
/* Begin filling in the checkpoint WAL record */
MemSet(&checkPoint, 0, sizeof(checkPoint));
checkPoint.time = (pg_time_t) time(NULL);
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index 8c98a114354..bfce29371fb 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -1385,7 +1385,9 @@ mdsync(void)
* counter is incremented here.
*
* This must be called *before* the checkpoint REDO point is determined.
- * That ensures that we won't delete files too soon.
+ * That ensures that we won't delete files too soon. Since this calls
+ * AbsorbFsyncRequests(), which performs memory allocations, it cannot be
+ * called within a critical section.
*
* Note that we can't do anything here that depends on the assumption
* that the checkpoint will be completed.
@@ -1394,6 +1396,16 @@ void
mdpreckpt(void)
{
/*
+ * Operations such as DROP TABLESPACE assume that the next checkpoint will
+ * process all recently forwarded unlink requests, but if they aren't
+ * absorbed prior to advancing the cycle counter, they won't be processed
+ * until a future checkpoint. The following absorb ensures that any
+ * unlink requests forwarded before the checkpoint began will be processed
+ * in the current checkpoint.
+ */
+ AbsorbFsyncRequests();
+
+ /*
* Any unlink requests arriving after this point will be assigned the next
* cycle counter, and won't be unlinked until next checkpoint.
*/