summaryrefslogtreecommitdiff
path: root/src/lsm
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2016-01-25 16:24:51 +1100
committerMichael Cahill <michael.cahill@mongodb.com>2016-01-25 16:24:51 +1100
commit7b479236ea199693f8f0905f8b91cd97b1f01b9d (patch)
treeb0271a55b3bc822a197be4cab0399f399a27d99c /src/lsm
parent5ad32a69c34b9ea4070d5321a53cf5e55bf0f5d0 (diff)
downloadmongo-7b479236ea199693f8f0905f8b91cd97b1f01b9d.tar.gz
WT-2346 Protect LSM flushes from racing with checkpoints.
Internal flush operations used to rely on the schema lock to avoid racing with checkpoints. That is no longer sufficient, use the checkpoint lock instead but also switch on "no wait" mode to avoid blocking for long periods while checkpoints are running.
Diffstat (limited to 'src/lsm')
-rw-r--r--src/lsm/lsm_work_unit.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/lsm/lsm_work_unit.c b/src/lsm/lsm_work_unit.c
index 4faa25967ad..dbaf8602846 100644
--- a/src/lsm/lsm_work_unit.c
+++ b/src/lsm/lsm_work_unit.c
@@ -334,14 +334,27 @@ __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session,
/*
* Turn on metadata tracking to ensure the checkpoint gets the
* necessary handle locks.
+ *
+ * Ensure that we don't race with a running checkpoint: the checkpoint
+ * lock protects against us racing with an application checkpoint in
+ * this chunk. Don't wait for it, though: checkpoints can take a long
+ * time, and our checkpoint operation should be very quick.
*/
WT_ERR(__wt_meta_track_on(session));
- WT_WITH_SCHEMA_LOCK(session, ret,
- ret = __wt_schema_worker(
- session, chunk->uri, __wt_checkpoint, NULL, NULL, 0));
+ F_SET(session, WT_SESSION_LOCK_NO_WAIT);
+ WT_WITH_CHECKPOINT_LOCK(session, ret,
+ WT_WITH_SCHEMA_LOCK(session, ret,
+ ret = __wt_schema_worker(
+ session, chunk->uri, __wt_checkpoint, NULL, NULL, 0)));
WT_TRET(__wt_meta_track_off(session, false, ret != 0));
- if (ret != 0)
+ F_CLR(session, WT_SESSION_LOCK_NO_WAIT);
+ if (ret != 0) {
+ if (ret == EBUSY) {
+ ret = 0;
+ goto err;
+ }
WT_ERR_MSG(session, ret, "LSM checkpoint");
+ }
/* Now the file is written, get the chunk size. */
WT_ERR(__wt_lsm_tree_set_chunk_size(session, chunk));