From 5cd1a45b08a4352ae119461d6b9dab03957c4228 Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Fri, 5 Oct 2012 17:35:29 +1000 Subject: Checkpoint the metadata after successful schema-level operations. Otherwise, if process exits without closing the connection or running a checkpoint, created objects exist but there is no record in the metadata. refs #350 --- src/meta/meta_track.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/meta/meta_track.c') diff --git a/src/meta/meta_track.c b/src/meta/meta_track.c index 6db4e1dd7bf..9adf19a4dbd 100644 --- a/src/meta/meta_track.c +++ b/src/meta/meta_track.c @@ -183,8 +183,10 @@ free: trk->op = WT_ST_EMPTY; int __wt_meta_track_off(WT_SESSION_IMPL *session, int unroll) { + WT_BTREE *saved_btree; WT_DECL_RET; WT_META_TRACK *trk, *trk_orig; + const char *ckpt_cfg[] = API_CONF_DEFAULTS(session, checkpoint, NULL); if (!WT_META_TRACKING(session)) return (0); @@ -198,6 +200,14 @@ __wt_meta_track_off(WT_SESSION_IMPL *session, int unroll) while (--trk >= trk_orig) WT_TRET(__meta_track_apply(session, trk, unroll)); + /* If the operation succeeded, checkpoint the metadata. */ + if (!unroll && ret == 0 && session->metafile != NULL) { + saved_btree = session->btree; + session->btree = session->metafile; + ret = __wt_checkpoint(session, ckpt_cfg); + session->btree = saved_btree; + } + return (ret); } -- cgit v1.2.1 From caa48be8d8031938297ce53604b6c9c6a0f2eff0 Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Thu, 25 Oct 2012 13:36:03 +1100 Subject: Allow meta_tracking transactions to be nested. Before this change, calls that performed an operation on multiple objects (such as creating a table that implicitly creates a column group) would checkpoint when the first nested child completed. This could leave the metadata incomplete if a process exited without calling `WT_CONNECTION::close`. closes #373 --- src/meta/meta_track.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/meta/meta_track.c') diff --git a/src/meta/meta_track.c b/src/meta/meta_track.c index 9adf19a4dbd..eec19d1990e 100644 --- a/src/meta/meta_track.c +++ b/src/meta/meta_track.c @@ -36,7 +36,7 @@ __meta_track_next(WT_SESSION_IMPL *session, WT_META_TRACK **trkp) { size_t offset, sub_off; - if (!WT_META_TRACKING(session)) + if (session->meta_track_next == NULL) session->meta_track_next = session->meta_track; offset = WT_PTRDIFF(session->meta_track_next, session->meta_track); @@ -83,7 +83,10 @@ __wt_meta_track_discard(WT_SESSION_IMPL *session) int __wt_meta_track_on(WT_SESSION_IMPL *session) { - return (__meta_track_next(session, NULL)); + if (session->meta_track_nest++ == 0) + WT_RET(__meta_track_next(session, NULL)); + + return (0); } static int @@ -188,7 +191,9 @@ __wt_meta_track_off(WT_SESSION_IMPL *session, int unroll) WT_META_TRACK *trk, *trk_orig; const char *ckpt_cfg[] = API_CONF_DEFAULTS(session, checkpoint, NULL); - if (!WT_META_TRACKING(session)) + WT_ASSERT(session, + WT_META_TRACKING(session) && session->meta_track_nest > 0); + if (--session->meta_track_nest != 0) return (0); trk_orig = session->meta_track; -- cgit v1.2.1 From 749bd436952b4788778a4654f298ec40bfe74f3f Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Wed, 19 Dec 2012 11:02:13 +0000 Subject: __wt_meta_track_off and __wt_lsm_checkpoint_worker create fake configuration strings to pass __wt_checkpoint so that __wt_checkpoint knows it's a checkpoint, not a file close. This is because we use __wt_schema_worker() to call __wt_checkpoint and there's no way to pass flags through __wt_schema_worker() to the underlying function. Fix this by creating two underlying functions, __wt_checkpoint and __wt_checkpoint_close, both of which can call __checkpoint_worker() with the right flags, and quit generating fake configuration strings in the places we're doing that. closes #416 --- src/meta/meta_track.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/meta/meta_track.c') diff --git a/src/meta/meta_track.c b/src/meta/meta_track.c index eec19d1990e..76622c21bf9 100644 --- a/src/meta/meta_track.c +++ b/src/meta/meta_track.c @@ -189,7 +189,6 @@ __wt_meta_track_off(WT_SESSION_IMPL *session, int unroll) WT_BTREE *saved_btree; WT_DECL_RET; WT_META_TRACK *trk, *trk_orig; - const char *ckpt_cfg[] = API_CONF_DEFAULTS(session, checkpoint, NULL); WT_ASSERT(session, WT_META_TRACKING(session) && session->meta_track_nest > 0); @@ -209,7 +208,7 @@ __wt_meta_track_off(WT_SESSION_IMPL *session, int unroll) if (!unroll && ret == 0 && session->metafile != NULL) { saved_btree = session->btree; session->btree = session->metafile; - ret = __wt_checkpoint(session, ckpt_cfg); + ret = __wt_checkpoint(session, NULL); session->btree = saved_btree; } -- cgit v1.2.1 From 963d37a4e6de35e74a7ebf534b725e692dbca8e9 Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Tue, 1 Jan 2013 09:45:50 +0000 Subject: Update copyright notice to 2013. --- src/meta/meta_track.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/meta/meta_track.c') diff --git a/src/meta/meta_track.c b/src/meta/meta_track.c index 76622c21bf9..6615d4d31a8 100644 --- a/src/meta/meta_track.c +++ b/src/meta/meta_track.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2008-2012 WiredTiger, Inc. + * Copyright (c) 2008-2013 WiredTiger, Inc. * All rights reserved. * * See the file LICENSE for redistribution information. -- cgit v1.2.1 From 4cb913ca29e7c88cb56409dbdb688f65277d748c Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Sat, 26 Jan 2013 13:20:08 -0500 Subject: In order to mmap read-only checkpoints, we need a place to store a per-checkpoint mapping. We don't currently have a per-checkpoint structure in the block manager, we only have the per-file WT_BLOCK. Add the WT_BM structure, which is a per-checkpoint structure. While we're in the area... Share the underlying WT_BLOCK structure between WT_BM structures, this means checkpoints into the file will share a single file descriptor. Give the WT_BM structure a set of method pointers, this is the change that we'd need to plug in other block managers. Some minor cleanups of size_t/uint32_t values. --- src/meta/meta_track.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/meta/meta_track.c') diff --git a/src/meta/meta_track.c b/src/meta/meta_track.c index 6615d4d31a8..46783fc5855 100644 --- a/src/meta/meta_track.c +++ b/src/meta/meta_track.c @@ -92,6 +92,7 @@ __wt_meta_track_on(WT_SESSION_IMPL *session) static int __meta_track_apply(WT_SESSION_IMPL *session, WT_META_TRACK *trk, int unroll) { + WT_BM *bm; WT_BTREE *saved_btree; WT_DECL_RET; int tret; @@ -109,8 +110,10 @@ __meta_track_apply(WT_SESSION_IMPL *session, WT_META_TRACK *trk, int unroll) case WT_ST_CHECKPOINT: /* Checkpoint, see above */ saved_btree = session->btree; session->btree = trk->btree; - if (!unroll) - WT_TRET(__wt_bm_checkpoint_resolve(session)); + if (!unroll) { + bm = trk->btree->bm; + WT_TRET(bm->checkpoint_resolve(bm, session)); + } session->btree = saved_btree; break; case WT_ST_LOCK: /* Handle lock, see above */ -- cgit v1.2.1