diff options
author | Keith Bostic <keith.bostic@mongodb.com> | 2017-08-14 02:14:00 -0400 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2017-08-14 16:14:00 +1000 |
commit | 71bb828bdca4f0efe1cbbcf717d83791817b0efa (patch) | |
tree | e45ca9eeaa3c21cf1c176be451770b5a51985cb9 | |
parent | 3418c859cb17ef008c799267a52dc48cebae4e5a (diff) | |
download | mongo-71bb828bdca4f0efe1cbbcf717d83791817b0efa.tar.gz |
WT-3493 wt_verbose_dump_txn should display timestamp information (#3580)
-rw-r--r-- | src/btree/bt_debug.c | 15 | ||||
-rw-r--r-- | src/include/extern.h | 1 | ||||
-rw-r--r-- | src/include/txn.i | 3 | ||||
-rw-r--r-- | src/txn/txn.c | 75 | ||||
-rw-r--r-- | src/txn/txn_timestamp.c | 11 |
5 files changed, 84 insertions, 21 deletions
diff --git a/src/btree/bt_debug.c b/src/btree/bt_debug.c index b8d11be7b3e..0e907ef25a8 100644 --- a/src/btree/bt_debug.c +++ b/src/btree/bt_debug.c @@ -1052,17 +1052,10 @@ __debug_update(WT_DBG *ds, WT_UPDATE *upd, bool hexbyte) #ifdef HAVE_TIMESTAMPS if (!__wt_timestamp_iszero( WT_TIMESTAMP_NULL(&upd->timestamp))) { -#if WT_TIMESTAMP_SIZE == 8 - WT_RET(ds->f(ds, - ", stamp %" PRIu64, upd->timestamp.val)); -#else - int i; - - WT_RET(ds->f(ds, ", stamp 0x")); - for (i = 0; i < WT_TIMESTAMP_SIZE; ++i) - WT_RET(ds->f(ds, - "%" PRIx8, upd->timestamp.ts[i])); -#endif + char hex_timestamp[2 * WT_TIMESTAMP_SIZE + 1]; + WT_RET(__wt_timestamp_to_hex_string( + ds->session, hex_timestamp, &upd->timestamp)); + WT_RET(ds->f(ds, ", stamp %s", hex_timestamp)); } #endif WT_RET(ds->f(ds, "\n")); diff --git a/src/include/extern.h b/src/include/extern.h index 5bb706fb801..4134001fb38 100644 --- a/src/include/extern.h +++ b/src/include/extern.h @@ -808,6 +808,7 @@ extern int __wt_txn_named_snapshot_config(WT_SESSION_IMPL *session, const char * extern void __wt_txn_named_snapshot_destroy(WT_SESSION_IMPL *session); extern int __wt_txn_recover(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_rollback_to_stable(WT_SESSION_IMPL *session, const char *cfg[]) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_timestamp_to_hex_string( WT_SESSION_IMPL *session, char *hex_timestamp, const wt_timestamp_t *ts_src) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_verbose_timestamp(WT_SESSION_IMPL *session, const wt_timestamp_t *ts, const char *msg); extern int __wt_txn_parse_timestamp(WT_SESSION_IMPL *session, const char *name, wt_timestamp_t *timestamp, WT_CONFIG_ITEM *cval) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_global_query_timestamp( WT_SESSION_IMPL *session, char *hex_timestamp, const char *cfg[]) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); diff --git a/src/include/txn.i b/src/include/txn.i index c4e8d5f04da..06d64275abe 100644 --- a/src/include/txn.i +++ b/src/include/txn.i @@ -90,8 +90,7 @@ __wt_timestamp_iszero(const wt_timestamp_t *ts) { static const wt_timestamp_t zero_timestamp; - return (memcmp(ts->ts, - WT_TIMESTAMP_NULL(&zero_timestamp), WT_TIMESTAMP_SIZE) == 0); + return (memcmp(ts->ts, &zero_timestamp, WT_TIMESTAMP_SIZE) == 0); } /* diff --git a/src/txn/txn.c b/src/txn/txn.c index d94fa15aa0c..6b5e0918b75 100644 --- a/src/txn/txn.c +++ b/src/txn/txn.c @@ -1050,7 +1050,9 @@ __wt_verbose_dump_txn(WT_SESSION_IMPL *session) const char *iso_tag; uint64_t id; uint32_t i, session_cnt; - +#ifdef HAVE_TIMESTAMPS + char hex_timestamp[3][2 * WT_TIMESTAMP_SIZE + 1]; +#endif conn = S2C(session); txn_global = &conn->txn_global; @@ -1061,10 +1063,35 @@ __wt_verbose_dump_txn(WT_SESSION_IMPL *session) WT_RET(__wt_msg(session, "last running ID: %" PRIu64, txn_global->last_running)); WT_RET(__wt_msg(session, "oldest ID: %" PRIu64, txn_global->oldest_id)); - WT_RET(__wt_msg(session, - "oldest named snapshot ID: %" PRIu64, txn_global->nsnap_oldest_id)); - WT_RET(__wt_msg(session, "checkpoint running? %s", +#ifdef HAVE_TIMESTAMPS + WT_RET(__wt_timestamp_to_hex_string( + session, hex_timestamp[0], &txn_global->commit_timestamp)); + WT_RET(__wt_msg(session, "commit timestamp: %s", hex_timestamp[0])); + WT_RET(__wt_timestamp_to_hex_string( + session, hex_timestamp[0], &txn_global->oldest_timestamp)); + WT_RET(__wt_msg(session, "oldest timestamp: %s", hex_timestamp[0])); + WT_RET(__wt_timestamp_to_hex_string( + session, hex_timestamp[0], &txn_global->pinned_timestamp)); + WT_RET(__wt_msg(session, "pinned timestamp: %s", hex_timestamp[0])); + WT_RET(__wt_timestamp_to_hex_string( + session, hex_timestamp[0], &txn_global->stable_timestamp)); + WT_RET(__wt_msg(session, "stable timestamp: %s", hex_timestamp[0])); + WT_RET(__wt_msg(session, "has_commit_timestamp: %s", + txn_global->has_commit_timestamp ? "yes" : "no")); + WT_RET(__wt_msg(session, "has_oldest_timestamp: %s", + txn_global->has_oldest_timestamp ? "yes" : "no")); + WT_RET(__wt_msg(session, "has_pinned_timestamp: %s", + txn_global->has_pinned_timestamp ? "yes" : "no")); + WT_RET(__wt_msg(session, "has_stable_timestamp: %s", + txn_global->has_stable_timestamp ? "yes" : "no")); + WT_RET(__wt_msg(session, "oldest_is_pinned: %s", + txn_global->oldest_is_pinned ? "yes" : "no")); + WT_RET(__wt_msg(session, "stable_is_pinned: %s", + txn_global->stable_is_pinned ? "yes" : "no")); +#endif + + WT_RET(__wt_msg(session, "checkpoint running: %s", txn_global->checkpoint_running ? "yes" : "no")); WT_RET(__wt_msg(session, "checkpoint generation: %" PRIu64, __wt_gen(session, WT_GEN_CHECKPOINT))); @@ -1073,9 +1100,11 @@ __wt_verbose_dump_txn(WT_SESSION_IMPL *session) WT_RET(__wt_msg(session, "checkpoint txn ID: %" PRIu64, txn_global->checkpoint_state.id)); + WT_RET(__wt_msg(session, + "oldest named snapshot ID: %" PRIu64, txn_global->nsnap_oldest_id)); + WT_ORDERED_READ(session_cnt, conn->session_cnt); WT_RET(__wt_msg(session, "session count: %" PRIu32, session_cnt)); - WT_RET(__wt_msg(session, "Transaction state of active sessions:")); /* @@ -1102,7 +1131,40 @@ __wt_verbose_dump_txn(WT_SESSION_IMPL *session) iso_tag = "WT_ISO_SNAPSHOT"; break; } - +#ifdef HAVE_TIMESTAMPS + WT_RET(__wt_timestamp_to_hex_string( + session, hex_timestamp[0], &txn->commit_timestamp)); + WT_RET(__wt_timestamp_to_hex_string( + session, hex_timestamp[1], &txn->first_commit_timestamp)); + WT_RET(__wt_timestamp_to_hex_string( + session, hex_timestamp[2], &txn->read_timestamp)); + WT_RET(__wt_msg(session, + "ID: %8" PRIu64 + ", mod count: %u" + ", pinned ID: %8" PRIu64 + ", snap min: %" PRIu64 + ", snap max: %" PRIu64 + ", commit_timestamp: %s" + ", first_commit_timestamp: %s" + ", read_timestamp: %s" + ", metadata pinned ID: %" PRIu64 + ", flags: 0x%08" PRIx32 + ", name: %s" + ", isolation: %s", + id, + txn->mod_count, + s->pinned_id, + txn->snap_min, + txn->snap_max, + hex_timestamp[0], + hex_timestamp[1], + hex_timestamp[2], + s->metadata_pinned, + txn->flags, + conn->sessions[i].name == NULL ? + "EMPTY" : conn->sessions[i].name, + iso_tag)); +#else WT_RET(__wt_msg(session, "ID: %6" PRIu64 ", mod count: %u" @@ -1123,6 +1185,7 @@ __wt_verbose_dump_txn(WT_SESSION_IMPL *session) conn->sessions[i].name == NULL ? "EMPTY" : conn->sessions[i].name, iso_tag)); +#endif } WT_RET(__wt_msg(session, "%s", WT_DIVIDER)); diff --git a/src/txn/txn_timestamp.c b/src/txn/txn_timestamp.c index 7e77f840c95..a947a0167ef 100644 --- a/src/txn/txn_timestamp.c +++ b/src/txn/txn_timestamp.c @@ -13,13 +13,20 @@ * __wt_timestamp_to_hex_string -- * Convert a timestamp to hex string representation. */ -static int +int __wt_timestamp_to_hex_string( WT_SESSION_IMPL *session, char *hex_timestamp, const wt_timestamp_t *ts_src) { wt_timestamp_t ts; __wt_timestamp_set(&ts, ts_src); + + if (__wt_timestamp_iszero(&ts)) { + hex_timestamp[0] = '0'; + hex_timestamp[1] = '\0'; + return (0); + } + #if WT_TIMESTAMP_SIZE == 8 { char *p, v; @@ -67,7 +74,7 @@ __wt_verbose_timestamp(WT_SESSION_IMPL *session, #ifdef HAVE_VERBOSE char timestamp_buf[2 * WT_TIMESTAMP_SIZE + 1]; - if (0 != __wt_timestamp_to_hex_string(session, timestamp_buf, ts)) + if (__wt_timestamp_to_hex_string(session, timestamp_buf, ts) != 0) return; __wt_verbose(session, |