summaryrefslogtreecommitdiff
path: root/src/meta/meta_track.c
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2015-03-26 14:11:30 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2015-03-26 14:11:30 +1100
commitfe5a1c3b0e5e51bf4980841233e6335c92d7dcf6 (patch)
tree230f9f415b081a6b6f257f848e1f90e9d6ec94a4 /src/meta/meta_track.c
parent3f7513d4616ac42cfd4c8891f4b237c7f5dfc8f1 (diff)
downloadmongo-fe5a1c3b0e5e51bf4980841233e6335c92d7dcf6.tar.gz
When we complete a schema-changing operation, make sure the metadata is stable. Here "schema-changing" implies that we are using the metadata tracking code, and "stable" means that either the log has been flushed or we checkpoint the metadata.
Diffstat (limited to 'src/meta/meta_track.c')
-rw-r--r--src/meta/meta_track.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/meta/meta_track.c b/src/meta/meta_track.c
index 85ca1732586..42955e734e1 100644
--- a/src/meta/meta_track.c
+++ b/src/meta/meta_track.c
@@ -188,7 +188,7 @@ free: trk->op = WT_ST_EMPTY;
* Turn off metadata operation tracking, unrolling on error.
*/
int
-__wt_meta_track_off(WT_SESSION_IMPL *session, int unroll)
+__wt_meta_track_off(WT_SESSION_IMPL *session, int sync, int unroll)
{
WT_DECL_RET;
WT_META_TRACK *trk, *trk_orig;
@@ -218,13 +218,28 @@ __wt_meta_track_off(WT_SESSION_IMPL *session, int unroll)
WT_TRET(__meta_track_apply(session, trk, unroll));
/*
- * If the operation succeeded and we aren't relying on the log for
- * durability, checkpoint the metadata.
+ * Unroll operations don't need to flush the metadata.
+ *
+ * Also, if we don't have the metadata handle (e.g, we're in the
+ * process of creating the metadata), we can't sync it.
*/
- if (!unroll && ret == 0 && session->meta_dhandle != NULL &&
- !FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED))
+ if (unroll || ret != 0 || !sync || session->meta_dhandle == NULL)
+ return (ret);
+
+ /* If we're logging, make sure the metadata update was flushed. */
+ if (FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED)) {
+ if (!FLD_ISSET(S2C(session)->txn_logsync,
+ WT_LOG_DSYNC | WT_LOG_FSYNC))
+ WT_WITH_DHANDLE(session, session->meta_dhandle,
+ ret = __wt_txn_checkpoint_log(session,
+ 0, WT_TXN_LOG_CKPT_SYNC, NULL));
+ } else {
WT_WITH_DHANDLE(session, session->meta_dhandle,
ret = __wt_checkpoint(session, NULL));
+ WT_RET(ret);
+ WT_WITH_DHANDLE(session, session->meta_dhandle,
+ ret = __wt_checkpoint_sync(session, NULL));
+ }
return (ret);
}