From 63be810eae384133fbc5c85cb39aa72c7d3f81f7 Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Tue, 11 Sep 2012 23:55:31 +1000 Subject: Fix locking of newly created handles, closing on error. --- src/meta/meta_track.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/meta') diff --git a/src/meta/meta_track.c b/src/meta/meta_track.c index 8d3b16fbc84..6db4e1dd7bf 100644 --- a/src/meta/meta_track.c +++ b/src/meta/meta_track.c @@ -23,6 +23,7 @@ typedef struct __wt_meta_track { } op; const char *a, *b; /* Strings */ WT_BTREE *btree; /* Locked handle */ + int created; /* Handle on newly created file */ } WT_META_TRACK; /* @@ -112,6 +113,8 @@ __meta_track_apply(WT_SESSION_IMPL *session, WT_META_TRACK *trk, int unroll) case WT_ST_LOCK: /* Handle lock, see above */ saved_btree = session->btree; session->btree = trk->btree; + if (unroll && trk->created) + F_SET(session->btree, WT_BTREE_DISCARD); WT_TRET(__wt_session_release_btree(session)); session->btree = saved_btree; break; @@ -130,8 +133,6 @@ __meta_track_apply(WT_SESSION_IMPL *session, WT_META_TRACK *trk, int unroll) trk->b, trk->a); WT_TRET(tret); } else if (trk->a == NULL) { - saved_btree = session->btree; - session->btree = saved_btree; if ((tret = __wt_remove(session, trk->b + strlen("file:"))) != 0) { __wt_err(session, tret, @@ -324,7 +325,7 @@ __wt_meta_track_fileop( * Track a locked handle. */ int -__wt_meta_track_handle_lock(WT_SESSION_IMPL *session) +__wt_meta_track_handle_lock(WT_SESSION_IMPL *session, int created) { WT_META_TRACK *trk; @@ -334,5 +335,6 @@ __wt_meta_track_handle_lock(WT_SESSION_IMPL *session) trk->op = WT_ST_LOCK; trk->btree = session->btree; + trk->created = created; return (0); } -- cgit v1.2.1