diff options
author | Alex Gorrod <alexander.gorrod@mongodb.com> | 2015-02-24 15:51:57 +1100 |
---|---|---|
committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2015-02-24 15:51:57 +1100 |
commit | 30fba4958170353caef3804f2cd113724f257298 (patch) | |
tree | fb6253735d6a5ec47762b6a63a8ccdcf0b612fff | |
parent | 303b826d41cf42b952517e4cec2a1003fd860e60 (diff) | |
parent | 17012ec16d78f996914a3dc0634ff50692ddf2f0 (diff) | |
download | mongo-30fba4958170353caef3804f2cd113724f257298.tar.gz |
Merge pull request #1695 from wiredtiger/statistics-sources-handle-overwrite
Statistics sources handle overwrite
-rw-r--r-- | src/conn/conn_dhandle.c | 21 | ||||
-rw-r--r-- | src/conn/conn_stat.c | 8 | ||||
-rw-r--r-- | src/evict/evict_lru.c | 2 | ||||
-rw-r--r-- | src/include/dhandle.h | 13 | ||||
-rw-r--r-- | src/meta/meta_apply.c | 3 | ||||
-rw-r--r-- | src/schema/schema_worker.c | 3 | ||||
-rw-r--r-- | src/txn/txn_ckpt.c | 5 | ||||
-rw-r--r-- | test/format/config.h | 4 | ||||
-rw-r--r-- | test/format/format.h | 1 | ||||
-rw-r--r-- | test/format/wts.c | 18 |
10 files changed, 55 insertions, 23 deletions
diff --git a/src/conn/conn_dhandle.c b/src/conn/conn_dhandle.c index 8ed656d6416..a5512352f2c 100644 --- a/src/conn/conn_dhandle.c +++ b/src/conn/conn_dhandle.c @@ -475,16 +475,15 @@ __conn_btree_apply_internal(WT_SESSION_IMPL *session, WT_DATA_HANDLE *dhandle, WT_DECL_RET; /* - * We need to pull the handle into the session handle - * cache and make sure it's referenced to stop other - * internal code dropping the handle (e.g in LSM when - * cleaning up obsolete chunks). Holding the metadata - * lock isn't enough. + * We need to pull the handle into the session handle cache and make + * sure it's referenced to stop other internal code dropping the handle + * (e.g in LSM when cleaning up obsolete chunks). */ ret = __wt_session_get_btree(session, dhandle->name, dhandle->checkpoint, NULL, 0); if (ret == 0) { - ret = func(session, cfg); + WT_SAVE_DHANDLE(session, + ret = func(session, cfg)); if (WT_META_TRACKING(session)) WT_TRET(__wt_meta_track_handle_lock(session, 0)); else @@ -550,12 +549,11 @@ __wt_conn_btree_apply_single(WT_SESSION_IMPL *session, int (*func)(WT_SESSION_IMPL *, const char *[]), const char *cfg[]) { WT_CONNECTION_IMPL *conn; - WT_DATA_HANDLE *dhandle, *saved_dhandle; + WT_DATA_HANDLE *dhandle; WT_DECL_RET; uint64_t bucket, hash; conn = S2C(session); - saved_dhandle = session->dhandle; WT_ASSERT(session, F_ISSET(session, WT_SESSION_HANDLE_LIST_LOCKED)); @@ -578,15 +576,14 @@ __wt_conn_btree_apply_single(WT_SESSION_IMPL *session, */ __wt_spin_lock(session, &dhandle->close_lock); if (F_ISSET(dhandle, WT_DHANDLE_OPEN)) { - session->dhandle = dhandle; - ret = func(session, cfg); + WT_WITH_DHANDLE(session, dhandle, + ret = func(session, cfg)); } __wt_spin_unlock(session, &dhandle->close_lock); WT_ERR(ret); } -err: session->dhandle = saved_dhandle; - return (ret); +err: return (ret); } /* diff --git a/src/conn/conn_stat.c b/src/conn/conn_stat.c index be2172ea8d8..67814dc330b 100644 --- a/src/conn/conn_stat.c +++ b/src/conn/conn_stat.c @@ -193,6 +193,7 @@ static int __statlog_apply(WT_SESSION_IMPL *session, const char *cfg[]) { WT_DATA_HANDLE *dhandle; + WT_DECL_RET; char **p; WT_UNUSED(cfg); @@ -201,8 +202,11 @@ __statlog_apply(WT_SESSION_IMPL *session, const char *cfg[]) /* Check for a match on the set of sources. */ for (p = S2C(session)->stat_sources; *p != NULL; ++p) - if (WT_PREFIX_MATCH(dhandle->name, *p)) - return (__statlog_dump(session, dhandle->name, 0)); + if (WT_PREFIX_MATCH(dhandle->name, *p)) { + WT_WITHOUT_DHANDLE(session, + ret = __statlog_dump(session, dhandle->name, 0)); + WT_RET(ret); + } return (0); } diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c index 78c34f0267e..35be3df9185 100644 --- a/src/evict/evict_lru.c +++ b/src/evict/evict_lru.c @@ -988,7 +988,7 @@ retry: while (slot < max_entries && ret == 0) { * exclusive access when a handle is being closed. */ if (!F_ISSET(btree, WT_BTREE_NO_EVICTION)) { - WT_WITH_BTREE(session, btree, + WT_WITH_DHANDLE(session, dhandle, ret = __evict_walk_file(session, &slot, flags)); WT_ASSERT(session, session->split_gen == 0); } diff --git a/src/include/dhandle.h b/src/include/dhandle.h index 423bb84d00d..300e8e735b9 100644 --- a/src/include/dhandle.h +++ b/src/include/dhandle.h @@ -6,6 +6,10 @@ * See the file LICENSE for redistribution information. */ +/* + * Helpers for calling a function with a data handle in session->dhandle + * then restoring afterwards. + */ #define WT_WITH_DHANDLE(s, d, e) do { \ WT_DATA_HANDLE *__saved_dhandle = (s)->dhandle; \ (s)->dhandle = (d); \ @@ -15,6 +19,15 @@ #define WT_WITH_BTREE(s, b, e) WT_WITH_DHANDLE(s, (b)->dhandle, e) +/* Call a function without the caller's data handle, restore afterwards. */ +#define WT_WITHOUT_DHANDLE(s, e) WT_WITH_DHANDLE(s, NULL, e) + +/* + * Call a function with the caller's data handle, restore it afterwards in case + * it is overwritten. + */ +#define WT_SAVE_DHANDLE(s, e) WT_WITH_DHANDLE(s, (s)->dhandle, e) + /* * WT_DATA_HANDLE -- * A handle for a generic named data source. diff --git a/src/meta/meta_apply.c b/src/meta/meta_apply.c index 8ef5cc38db4..6d08ce3aa6a 100644 --- a/src/meta/meta_apply.c +++ b/src/meta/meta_apply.c @@ -43,7 +43,8 @@ __wt_meta_btree_apply(WT_SESSION_IMPL *session, */ ret = __wt_session_get_btree(session, uri, NULL, NULL, 0); if (ret == 0) { - ret = func(session, cfg); + WT_SAVE_DHANDLE(session, + ret = func(session, cfg)); if (WT_META_TRACKING(session)) WT_TRET( __wt_meta_track_handle_lock(session, 0)); diff --git a/src/schema/schema_worker.c b/src/schema/schema_worker.c index 94eb3170175..3dfd068cf9c 100644 --- a/src/schema/schema_worker.c +++ b/src/schema/schema_worker.c @@ -57,7 +57,8 @@ __wt_schema_worker(WT_SESSION_IMPL *session, WT_ERR(__wt_session_get_btree_ckpt( session, uri, cfg, open_flags)); - ret = file_func(session, cfg); + WT_SAVE_DHANDLE(session, + ret = file_func(session, cfg)); WT_TRET(__wt_session_release_btree(session)); } } else if (WT_PREFIX_MATCH(uri, "colgroup:")) { diff --git a/src/txn/txn_ckpt.c b/src/txn/txn_ckpt.c index eae21d0b9f5..fb590e1a297 100644 --- a/src/txn/txn_ckpt.c +++ b/src/txn/txn_ckpt.c @@ -237,7 +237,6 @@ __checkpoint_data_source(WT_SESSION_IMPL *session, const char *cfg[]) int __wt_checkpoint_list(WT_SESSION_IMPL *session, const char *cfg[]) { - WT_DATA_HANDLE *saved_dhandle; WT_DECL_RET; const char *name; @@ -253,7 +252,6 @@ __wt_checkpoint_list(WT_SESSION_IMPL *session, const char *cfg[]) /* Not strictly necessary, but cleaner to clear the current handle. */ name = session->dhandle->name; - saved_dhandle = session->dhandle; session->dhandle = NULL; /* Record busy file names, we'll deal with them in the checkpoint. */ @@ -264,8 +262,7 @@ __wt_checkpoint_list(WT_SESSION_IMPL *session, const char *cfg[]) WT_ERR(__wt_strdup(session, name, &session->ckpt_handle[session->ckpt_handle_next++].name)); -err: session->dhandle = saved_dhandle; - return (ret); +err: return (ret); } /* diff --git a/test/format/config.h b/test/format/config.h index 01357d6fb30..7871127ff26 100644 --- a/test/format/config.h +++ b/test/format/config.h @@ -261,6 +261,10 @@ static CONFIG c[] = { "maintain statistics", /* 20% */ C_BOOL, 20, 0, 0, &g.c_statistics, NULL }, + { "statistics_server", + "run the statistics server thread", /* 5% */ + C_BOOL, 5, 0, 0, &g.c_statistics_server, NULL }, + { "threads", "the number of threads", C_IGNORE, 1, 32, 128, &g.c_threads, NULL }, diff --git a/test/format/format.h b/test/format/format.h index 9adb56c82fb..e2cd4f19c7e 100644 --- a/test/format/format.h +++ b/test/format/format.h @@ -215,6 +215,7 @@ typedef struct { uint32_t c_runs; uint32_t c_split_pct; uint32_t c_statistics; + uint32_t c_statistics_server; uint32_t c_threads; uint32_t c_timer; uint32_t c_value_max; diff --git a/test/format/wts.c b/test/format/wts.c index b36655aacbe..0875f3900f8 100644 --- a/test/format/wts.c +++ b/test/format/wts.c @@ -121,8 +121,22 @@ wts_open(const char *home, int set_api, WT_CONNECTION **connp) if (g.c_data_extend) p += snprintf(p, REMAIN(p, end), ",file_extend=(data=8MB)"); - p += snprintf(p, REMAIN(p, end), - ",statistics=(%s)", g.c_statistics ? "fast" : "none"); + /* + * Run the statistics server and/or maintain statistics in the engine. + * Sometimes specify a set of sources just to exercise that code. + */ + if (g.c_statistics_server) { + if (MMRAND(0, 5) == 1 && + memcmp(g.uri, "file:", strlen("file:")) == 0) + p += snprintf(p, REMAIN(p, end), + ",statistics=(fast)" + ",statistics_log=(wait=5,sources=(\"file:\"))"); + else + p += snprintf(p, REMAIN(p, end), + ",statistics=(fast),statistics_log=(wait=5)"); + } else + p += snprintf(p, REMAIN(p, end), + ",statistics=(%s)", g.c_statistics ? "fast" : "none"); /* Extensions. */ p += snprintf(p, REMAIN(p, end), |