diff options
author | Luke Chen <luke.chen@mongodb.com> | 2018-11-26 14:26:36 +1100 |
---|---|---|
committer | Luke Chen <luke.chen@mongodb.com> | 2018-11-26 14:26:36 +1100 |
commit | 406d650b57a00bbc66e616ebbb5b22112a0621aa (patch) | |
tree | c245e765d3c6eadc7b9be82e216557cf2e43159e /src/third_party/wiredtiger/src | |
parent | da22c83c0e2d4d9b1e014b183a21898443dbc128 (diff) | |
download | mongo-406d650b57a00bbc66e616ebbb5b22112a0621aa.tar.gz |
Import wiredtiger: 74aa2f92a95596196d8ff131cdf015850613c893 from branch mongodb-4.2
ref: a065c83d8d..74aa2f92a9
for: 4.1.6
WT-3756 Adjust pre-allocated file amount downward if we're not using them quickly enough
WT-4381 Reset session statistics as on WT_SESSION::reset()
WT-4394 Reduce Evergreen Ubuntu build variant runtime by splitting up 'make check' tests
WT-4419 big-endian machines incorrectly configure little-endian crc32c support
WT-4427 Make WiredTiger timestamps always on and 8 bytes
WT-4440 Force a copy of the stable timestamp for clarity
Diffstat (limited to 'src/third_party/wiredtiger/src')
47 files changed, 473 insertions, 1068 deletions
diff --git a/src/third_party/wiredtiger/src/btree/bt_debug.c b/src/third_party/wiredtiger/src/btree/bt_debug.c index 3ffc63d94ba..bedcf37d9f8 100644 --- a/src/third_party/wiredtiger/src/btree/bt_debug.c +++ b/src/third_party/wiredtiger/src/btree/bt_debug.c @@ -1173,6 +1173,8 @@ __debug_modify(WT_DBG *ds, WT_UPDATE *upd) static int __debug_update(WT_DBG *ds, WT_UPDATE *upd, bool hexbyte) { + char hex_timestamp[WT_TS_HEX_SIZE]; + for (; upd != NULL; upd = upd->next) { switch (upd->type) { case WT_UPDATE_INVALID: @@ -1207,15 +1209,11 @@ __debug_update(WT_DBG *ds, WT_UPDATE *upd, bool hexbyte) else WT_RET(ds->f(ds, "\t" "txn id %" PRIu64, upd->txnid)); -#ifdef HAVE_TIMESTAMPS - if (!__wt_timestamp_iszero( - WT_TIMESTAMP_NULL(&upd->timestamp))) { - char hex_timestamp[2 * WT_TIMESTAMP_SIZE + 1]; - WT_RET(__wt_timestamp_to_hex_string( - ds->session, hex_timestamp, &upd->timestamp)); + if (upd->timestamp != 0) { + __wt_timestamp_to_hex_string( + hex_timestamp, upd->timestamp); WT_RET(ds->f(ds, ", stamp %s", hex_timestamp)); } -#endif WT_RET(ds->f(ds, "\n")); } return (0); diff --git a/src/third_party/wiredtiger/src/btree/bt_delete.c b/src/third_party/wiredtiger/src/btree/bt_delete.c index 496d59c947c..67367e3d752 100644 --- a/src/third_party/wiredtiger/src/btree/bt_delete.c +++ b/src/third_party/wiredtiger/src/btree/bt_delete.c @@ -295,7 +295,7 @@ __wt_delete_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, bool visible_all) */ if (skip && ref->page_del != NULL && (visible_all || __wt_txn_visible_all(session, ref->page_del->txnid, - WT_TIMESTAMP_NULL(&ref->page_del->timestamp)))) { + ref->page_del->timestamp))) { __wt_free(session, ref->page_del->update_list); __wt_free(session, ref->page_del); } @@ -323,7 +323,7 @@ __tombstone_update_alloc(WT_SESSION_IMPL *session, */ if (page_del != NULL) { upd->txnid = page_del->txnid; - __wt_timestamp_set(&upd->timestamp, &page_del->timestamp); + upd->timestamp = page_del->timestamp; upd->prepare_state = page_del->prepare_state; } *updp = upd; diff --git a/src/third_party/wiredtiger/src/btree/bt_read.c b/src/third_party/wiredtiger/src/btree/bt_read.c index 85597710bc5..f6f7212eb85 100644 --- a/src/third_party/wiredtiger/src/btree/bt_read.c +++ b/src/third_party/wiredtiger/src/btree/bt_read.c @@ -120,9 +120,10 @@ __las_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref) WT_CURSOR_BTREE cbt; WT_DECL_ITEM(current_key); WT_DECL_RET; - WT_ITEM las_key, las_timestamp, las_value; + WT_ITEM las_key, las_value; WT_PAGE *page; WT_UPDATE *first_upd, *last_upd, *upd; + wt_timestamp_t las_timestamp; size_t incr, total_incr; uint64_t current_recno, las_counter, las_pageid, las_txnid, recno; uint32_t las_id, session_flags; @@ -187,11 +188,8 @@ __las_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref) session, &las_value, &upd, &incr, upd_type)); total_incr += incr; upd->txnid = las_txnid; + upd->timestamp = las_timestamp; upd->prepare_state = prepare_state; -#ifdef HAVE_TIMESTAMPS - WT_ASSERT(session, las_timestamp.size == WT_TIMESTAMP_SIZE); - memcpy(&upd->timestamp, las_timestamp.data, las_timestamp.size); -#endif switch (page->type) { case WT_PAGE_COL_FIX: @@ -284,10 +282,10 @@ __las_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref) !ref->page_las->has_prepares && !S2C(session)->txn_global.has_stable_timestamp && __wt_txn_visible_all(session, ref->page_las->unstable_txn, - WT_TIMESTAMP_NULL(&ref->page_las->unstable_timestamp))) { + ref->page_las->unstable_timestamp)) { page->modify->rec_max_txn = ref->page_las->max_txn; - __wt_timestamp_set(&page->modify->rec_max_timestamp, - &ref->page_las->max_timestamp); + page->modify->rec_max_timestamp = + ref->page_las->max_timestamp; __wt_page_modify_clear(session, page); } } diff --git a/src/third_party/wiredtiger/src/btree/bt_split.c b/src/third_party/wiredtiger/src/btree/bt_split.c index 2f2023917eb..b2e0883010d 100644 --- a/src/third_party/wiredtiger/src/btree/bt_split.c +++ b/src/third_party/wiredtiger/src/btree/bt_split.c @@ -1531,15 +1531,12 @@ __split_multi_inmem( */ mod->last_evict_pass_gen = orig->modify->last_evict_pass_gen; mod->last_eviction_id = orig->modify->last_eviction_id; - __wt_timestamp_set(&mod->last_eviction_timestamp, - &orig->modify->last_eviction_timestamp); + mod->last_eviction_timestamp = orig->modify->last_eviction_timestamp; /* Add the update/restore flag to any previous state. */ - __wt_timestamp_set(&mod->last_stable_timestamp, - &orig->modify->last_stable_timestamp); + mod->last_stable_timestamp = orig->modify->last_stable_timestamp; mod->rec_max_txn = orig->modify->rec_max_txn; - __wt_timestamp_set(&mod->rec_max_timestamp, - &orig->modify->rec_max_timestamp); + mod->rec_max_timestamp = orig->modify->rec_max_timestamp; mod->restore_state = orig->modify->restore_state; FLD_SET(mod->restore_state, WT_PAGE_RS_RESTORED); diff --git a/src/third_party/wiredtiger/src/btree/bt_sync.c b/src/third_party/wiredtiger/src/btree/bt_sync.c index c5c08faa701..c6d1d2d18ea 100644 --- a/src/third_party/wiredtiger/src/btree/bt_sync.c +++ b/src/third_party/wiredtiger/src/btree/bt_sync.c @@ -269,14 +269,11 @@ __sync_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop) if (((mod = walk->page->modify) != NULL) && mod->rec_max_txn > btree->rec_max_txn) btree->rec_max_txn = mod->rec_max_txn; -#ifdef HAVE_TIMESTAMPS - if (mod != NULL && __wt_timestamp_cmp( - &btree->rec_max_timestamp, - &mod->rec_max_timestamp) < 0) - __wt_timestamp_set( - &btree->rec_max_timestamp, - &mod->rec_max_timestamp); -#endif + if (mod != NULL && + btree->rec_max_timestamp < + mod->rec_max_timestamp) + btree->rec_max_timestamp = + mod->rec_max_timestamp; continue; } diff --git a/src/third_party/wiredtiger/src/btree/row_modify.c b/src/third_party/wiredtiger/src/btree/row_modify.c index b7f889c6356..c2da7318fd3 100644 --- a/src/third_party/wiredtiger/src/btree/row_modify.c +++ b/src/third_party/wiredtiger/src/btree/row_modify.c @@ -356,13 +356,9 @@ __wt_update_obsolete_check( */ if (count > 20 && page->modify != NULL) { page->modify->obsolete_check_txn = txn_global->last_running; -#ifdef HAVE_TIMESTAMPS if (txn_global->has_pinned_timestamp) - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - __wt_timestamp_set( - &page->modify->obsolete_check_timestamp, - &txn_global->pinned_timestamp)); -#endif + page->modify->obsolete_check_timestamp = + txn_global->pinned_timestamp; } return (NULL); diff --git a/src/third_party/wiredtiger/src/cache/cache_las.c b/src/third_party/wiredtiger/src/cache/cache_las.c index 94986a184e7..411132b6e13 100644 --- a/src/third_party/wiredtiger/src/cache/cache_las.c +++ b/src/third_party/wiredtiger/src/cache/cache_las.c @@ -421,14 +421,12 @@ __wt_las_page_skip_locked(WT_SESSION_IMPL *session, WT_REF *ref) if (!F_ISSET(txn, WT_TXN_HAS_TS_READ)) return (ref->page_las->skew_newest); -#ifdef HAVE_TIMESTAMPS /* * Skip lookaside pages if reading as of a timestamp, we evicted new * versions of data and all the updates are in the past. */ if (ref->page_las->skew_newest && - __wt_timestamp_cmp( - &txn->read_timestamp, &ref->page_las->unstable_timestamp) > 0) + txn->read_timestamp > ref->page_las->unstable_timestamp) return (true); /* @@ -436,10 +434,8 @@ __wt_las_page_skip_locked(WT_SESSION_IMPL *session, WT_REF *ref) * versions of data and all the unstable updates are in the future. */ if (!ref->page_las->skew_newest && - __wt_timestamp_cmp( - &txn->read_timestamp, &ref->page_las->unstable_timestamp) < 0) + txn->read_timestamp < ref->page_las->unstable_timestamp) return (true); -#endif return (false); } @@ -540,7 +536,7 @@ err: if (local_txn) { * Display a verbose message once per checkpoint with details about the * cache state when performing a lookaside table write. */ -static int +static void __las_insert_block_verbose( WT_SESSION_IMPL *session, WT_BTREE *btree, WT_MULTI *multi) { @@ -549,16 +545,14 @@ __las_insert_block_verbose( double pct_dirty, pct_full; uint64_t ckpt_gen_current, ckpt_gen_last; uint32_t btree_id; -#ifdef HAVE_TIMESTAMPS - char hex_timestamp[2 * WT_TIMESTAMP_SIZE + 1]; -#endif + char hex_timestamp[WT_TS_HEX_SIZE]; const char *ts; btree_id = btree->id; if (!WT_VERBOSE_ISSET(session, WT_VERB_LOOKASIDE | WT_VERB_LOOKASIDE_ACTIVITY)) - return (0); + return; conn = S2C(session); cache = conn->cache; @@ -577,13 +571,9 @@ __las_insert_block_verbose( (void)__wt_eviction_clean_needed(session, &pct_full); (void)__wt_eviction_dirty_needed(session, &pct_dirty); -#ifdef HAVE_TIMESTAMPS - WT_RET(__wt_timestamp_to_hex_string(session, hex_timestamp, - &multi->page_las.unstable_timestamp)); + __wt_timestamp_to_hex_string( + hex_timestamp, multi->page_las.unstable_timestamp); ts = hex_timestamp; -#else - ts = "disabled"; -#endif __wt_verbose(session, WT_VERB_LOOKASIDE | WT_VERB_LOOKASIDE_ACTIVITY, "Page reconciliation triggered lookaside write " @@ -603,7 +593,6 @@ __las_insert_block_verbose( /* Never skip updating the tracked generation */ if (WT_VERBOSE_ISSET(session, WT_VERB_LOOKASIDE)) cache->las_verb_gen_write = ckpt_gen_current; - return (0); } /* @@ -616,28 +605,23 @@ __wt_las_insert_block(WT_CURSOR *cursor, { WT_CONNECTION_IMPL *conn; WT_DECL_RET; - WT_DECL_TIMESTAMP(prev_timestamp) - WT_ITEM las_timestamp, las_value; + WT_ITEM las_value; WT_SAVE_UPD *list; WT_SESSION_IMPL *session; WT_TXN_ISOLATION saved_isolation; WT_UPDATE *upd; - uint64_t insert_cnt, prepared_insert_cnt; - uint64_t las_counter, las_pageid; + uint64_t insert_cnt, las_counter, las_pageid, prepared_insert_cnt; uint32_t btree_id, i, slot; uint8_t *p; bool local_txn; session = (WT_SESSION_IMPL *)cursor->session; conn = S2C(session); - WT_CLEAR(las_timestamp); WT_CLEAR(las_value); insert_cnt = prepared_insert_cnt = 0; btree_id = btree->id; local_txn = false; - __wt_timestamp_set_zero(&prev_timestamp); - las_pageid = __wt_atomic_add64(&conn->cache->las_pageid, 1); if (!btree->lookaside_entries) @@ -732,10 +716,6 @@ __wt_las_insert_block(WT_CURSOR *cursor, cursor->set_key(cursor, las_pageid, btree_id, ++las_counter, key); -#ifdef HAVE_TIMESTAMPS - las_timestamp.data = &upd->timestamp; - las_timestamp.size = WT_TIMESTAMP_SIZE; -#endif /* * If saving a non-zero length value on the page, save a * birthmark instead of duplicating it in the lookaside @@ -748,11 +728,11 @@ __wt_las_insert_block(WT_CURSOR *cursor, upd->type == WT_UPDATE_MODIFY)) { las_value.size = 0; cursor->set_value(cursor, upd->txnid, - &las_timestamp, upd->prepare_state, + upd->timestamp, upd->prepare_state, WT_UPDATE_BIRTHMARK, &las_value); } else cursor->set_value(cursor, upd->txnid, - &las_timestamp, upd->prepare_state, + upd->timestamp, upd->prepare_state, upd->type, &las_value); /* @@ -790,7 +770,7 @@ err: /* Resolve the transaction. */ if (ret == 0 && insert_cnt > 0) { multi->page_las.las_pageid = las_pageid; multi->page_las.has_prepares = prepared_insert_cnt > 0; - ret = __las_insert_block_verbose(session, btree, multi); + __las_insert_block_verbose(session, btree, multi); } return (ret); @@ -996,14 +976,10 @@ __wt_las_sweep(WT_SESSION_IMPL *session) WT_CURSOR *cursor; WT_DECL_ITEM(saved_key); WT_DECL_RET; - WT_ITEM las_key, las_timestamp, las_value; + WT_ITEM las_key, las_value; WT_ITEM *sweep_key; WT_TXN_ISOLATION saved_isolation; -#ifdef HAVE_TIMESTAMPS - wt_timestamp_t timestamp, *val_ts; -#else - wt_timestamp_t *val_ts; -#endif + wt_timestamp_t las_timestamp; uint64_t cnt, remove_cnt, las_pageid, saved_pageid, visit_cnt; uint64_t las_counter, las_txnid; uint32_t las_id, session_flags; @@ -1129,13 +1105,6 @@ __wt_las_sweep(WT_SESSION_IMPL *session) */ WT_ERR(cursor->get_value(cursor, &las_txnid, &las_timestamp, &prepare_state, &upd_type, &las_value)); -#ifdef HAVE_TIMESTAMPS - WT_ASSERT(session, las_timestamp.size == WT_TIMESTAMP_SIZE); - memcpy(×tamp, las_timestamp.data, las_timestamp.size); - val_ts = ×tamp; -#else - val_ts = NULL; -#endif /* * Check to see if the page or key has changed this iteration, @@ -1166,7 +1135,8 @@ __wt_las_sweep(WT_SESSION_IMPL *session) * * The entry wasn't from a prepared transaction. */ if (upd_type == WT_UPDATE_BIRTHMARK && - __wt_txn_visible_all(session, las_txnid, val_ts) && + __wt_txn_visible_all( + session, las_txnid, las_timestamp) && prepare_state != WT_PREPARE_INPROGRESS) removing_key_block = true; else diff --git a/src/third_party/wiredtiger/src/checksum/arm64/crc32-arm64.c b/src/third_party/wiredtiger/src/checksum/arm64/crc32-arm64.c index 240c2a421bf..6d9d0919ec6 100644 --- a/src/third_party/wiredtiger/src/checksum/arm64/crc32-arm64.c +++ b/src/third_party/wiredtiger/src/checksum/arm64/crc32-arm64.c @@ -26,15 +26,10 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include <wiredtiger_config.h> #include <inttypes.h> #include <stddef.h> -/* - * The checksum code doesn't include WiredTiger configuration or include files. - * This means the HAVE_NO_CRC32_HARDWARE #define isn't configurable as part of - * standalone WiredTiger configuration, there's no way to turn off the checksum - * hardware. - */ #if defined(__linux__) && !defined(HAVE_NO_CRC32_HARDWARE) #include <asm/hwcap.h> #include <sys/auxv.h> diff --git a/src/third_party/wiredtiger/src/checksum/power8/crc32.sx b/src/third_party/wiredtiger/src/checksum/power8/crc32.sx index f8a89cd7c06..3eca99bdc53 100644 --- a/src/third_party/wiredtiger/src/checksum/power8/crc32.sx +++ b/src/third_party/wiredtiger/src/checksum/power8/crc32.sx @@ -1,9 +1,4 @@ -/* - * The checksum code doesn't include WiredTiger configuration or include files. - * This means the HAVE_NO_CRC32_HARDWARE #define isn't configurable as part of - * standalone WiredTiger configuration, there's no way to turn off the checksum - * hardware. - */ +#include <wiredtiger_config.h> #if defined(__powerpc64__) && !defined(HAVE_NO_CRC32_HARDWARE) /* diff --git a/src/third_party/wiredtiger/src/checksum/power8/crc32_wrapper.c b/src/third_party/wiredtiger/src/checksum/power8/crc32_wrapper.c index 074891eb0e7..343df75339e 100644 --- a/src/third_party/wiredtiger/src/checksum/power8/crc32_wrapper.c +++ b/src/third_party/wiredtiger/src/checksum/power8/crc32_wrapper.c @@ -1,12 +1,7 @@ +#include <wiredtiger_config.h> #include <inttypes.h> #include <stddef.h> -/* - * The checksum code doesn't include WiredTiger configuration or include files. - * This means the HAVE_NO_CRC32_HARDWARE #define isn't configurable as part of - * standalone WiredTiger configuration, there's no way to turn off the checksum - * hardware. - */ #if defined(__powerpc64__) && !defined(HAVE_NO_CRC32_HARDWARE) #define CRC_TABLE #include "crc32_constants.h" diff --git a/src/third_party/wiredtiger/src/checksum/software/checksum.c b/src/third_party/wiredtiger/src/checksum/software/checksum.c index 4d93f8bf1ea..d024d2693f4 100644 --- a/src/third_party/wiredtiger/src/checksum/software/checksum.c +++ b/src/third_party/wiredtiger/src/checksum/software/checksum.c @@ -38,6 +38,7 @@ * little endian. */ +#include <wiredtiger_config.h> #include <inttypes.h> #include <stddef.h> diff --git a/src/third_party/wiredtiger/src/checksum/x86/crc32-x86.c b/src/third_party/wiredtiger/src/checksum/x86/crc32-x86.c index 70860019e02..40dab199ff3 100644 --- a/src/third_party/wiredtiger/src/checksum/x86/crc32-x86.c +++ b/src/third_party/wiredtiger/src/checksum/x86/crc32-x86.c @@ -26,15 +26,10 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include <wiredtiger_config.h> #include <inttypes.h> #include <stddef.h> -/* - * The checksum code doesn't include WiredTiger configuration or include files. - * This means the HAVE_NO_CRC32_HARDWARE #define isn't configurable as part of - * standalone WiredTiger configuration, there's no way to turn off the checksum - * hardware. - */ #if !defined(HAVE_NO_CRC32_HARDWARE) #if (defined(__amd64) || defined(__x86_64)) /* diff --git a/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c b/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c index 9c7ae30bf71..5edd5775478 100644 --- a/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c +++ b/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c @@ -7,17 +7,12 @@ * */ +#include <wiredtiger_config.h> #include <sys/types.h> #include <endian.h> #include <inttypes.h> #include <stddef.h> -/* - * The checksum code doesn't include WiredTiger configuration or include files. - * This means the HAVE_NO_CRC32_HARDWARE #define isn't configurable as part of - * standalone WiredTiger configuration, there's no way to turn off the checksum - * hardware. - */ #if defined(__linux__) && !defined(HAVE_NO_CRC32_HARDWARE) #include <sys/auxv.h> diff --git a/src/third_party/wiredtiger/src/checksum/zseries/crc32le-vx.sx b/src/third_party/wiredtiger/src/checksum/zseries/crc32le-vx.sx index 41ee20d3e94..1bfdddc3181 100644 --- a/src/third_party/wiredtiger/src/checksum/zseries/crc32le-vx.sx +++ b/src/third_party/wiredtiger/src/checksum/zseries/crc32le-vx.sx @@ -1,9 +1,4 @@ -/* - * The checksum code doesn't include WiredTiger configuration or include files. - * This means the HAVE_NO_CRC32_HARDWARE #define isn't configurable as part of - * standalone WiredTiger configuration, there's no way to turn off the checksum - * hardware. - */ +#include <wiredtiger_config.h> #if !defined(HAVE_NO_CRC32_HARDWARE) /* diff --git a/src/third_party/wiredtiger/src/conn/conn_log.c b/src/third_party/wiredtiger/src/conn/conn_log.c index 0039533f407..dc6e4a82509 100644 --- a/src/third_party/wiredtiger/src/conn/conn_log.c +++ b/src/third_party/wiredtiger/src/conn/conn_log.c @@ -447,7 +447,18 @@ __log_prealloc_once(WT_SESSION_IMPL *session) __wt_verbose(session, WT_VERB_LOG, "Missed %" PRIu32 ". Now pre-allocating up to %" PRIu32, log->prep_missed, conn->log_prealloc); + } else if (reccount > conn->log_prealloc / 2 && + conn->log_prealloc > 2) { + /* + * If we used less than half, then start adjusting down. + */ + --conn->log_prealloc; + __wt_verbose(session, WT_VERB_LOG, + "Adjust down. Did not use %" PRIu32 + ". Now pre-allocating %" PRIu32, + reccount, conn->log_prealloc); } + WT_STAT_CONN_SET(session, log_prealloc_max, conn->log_prealloc); /* * Allocate up to the maximum number that we just computed and detected. diff --git a/src/third_party/wiredtiger/src/conn/conn_sweep.c b/src/third_party/wiredtiger/src/conn/conn_sweep.c index 734c455d854..78e0c8f9fc2 100644 --- a/src/third_party/wiredtiger/src/conn/conn_sweep.c +++ b/src/third_party/wiredtiger/src/conn/conn_sweep.c @@ -85,7 +85,7 @@ __sweep_expire_one(WT_SESSION_IMPL *session) /* Only sweep clean trees where all updates are visible. */ if (btree != NULL && (btree->modified || !__wt_txn_visible_all(session, - btree->rec_max_txn, WT_TIMESTAMP_NULL(&btree->rec_max_timestamp)))) + btree->rec_max_txn, btree->rec_max_timestamp))) goto err; /* diff --git a/src/third_party/wiredtiger/src/cursor/cur_stat.c b/src/third_party/wiredtiger/src/cursor/cur_stat.c index 4a49a2a141e..a65043b138a 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_stat.c +++ b/src/third_party/wiredtiger/src/cursor/cur_stat.c @@ -515,19 +515,19 @@ __curstat_join_init(WT_SESSION_IMPL *session, /* * __curstat_session_init -- - * Initialize the statistics for a session operation. + * Initialize the statistics for a session. */ static void __curstat_session_init(WT_SESSION_IMPL *session, WT_CURSOR_STAT *cst) { /* This is a stub at the moment, initialize the session stats to 0. */ session->stats.bytes_read = 0; - session->stats.bytes_written = 0; + session->stats.bytes_write = 0; + session->stats.cache_time = 0; + session->stats.lock_dhandle_wait = 0; + session->stats.lock_schema_wait = 0; session->stats.read_time = 0; session->stats.write_time = 0; - session->stats.cache_full_wait = 0; - session->stats.schema_lock_wait = 0; - session->stats.handle_lock_wait = 0; /* * Copy stats from the session to the cursor. Optionally clear the diff --git a/src/third_party/wiredtiger/src/docs/transactions.dox b/src/third_party/wiredtiger/src/docs/transactions.dox index 917986f7df3..255cba4cb52 100644 --- a/src/third_party/wiredtiger/src/docs/transactions.dox +++ b/src/third_party/wiredtiger/src/docs/transactions.dox @@ -157,19 +157,12 @@ Named snapshots are not durable: they do not survive WT_CONNECTION::close. Some applications have their own notion of time, including an expected commit order for transactions that may be inconsistent with the order assigned by -WiredTiger. We assume that applications can represent their notion of a -timestamp as an unsigned integral value of some size that generally increases -over time. For example, a simple 64-bit integer could be incremented to -generate transaction timestamps, if that is sufficient for the application. - -The application's timestamp size is specified as a number of bytes at build -time, with <code>configure --with-timestamp-size=X</code>. The default -timestamp size is 8 bytes (i.e., 64 bits). Setting a size of zero disables -transaction timestamp functionality. Timestamps are communicated to WiredTiger -using a hexadecimal encoding, so the encoded value can be twice as long as the -raw timestamp value. - -Applications assign explicit commit timestamps to transactions, then read +WiredTiger. We assume applications can represent their notion of a timestamp +as an unsigned 64-bit integral value that generally increases over time. For +example, a counter could be incremented to generate transaction timestamps, +if that is sufficient for the application. + +Applications can assign explicit commit timestamps to transactions, then read "as of" a timestamp. The timestamp mechanism operates in parallel with WiredTiger's internal transaction ID management. It is recommended that once timestamps are in use for a particular table, all subsequent updates also use @@ -180,7 +173,7 @@ timestamps. Applications that use timestamps will generally provide a timestamp at WT_SESSION::transaction_commit that will be assigned to all updates that are part of the transaction. WiredTiger also provides the ability to set a different -commit timestamp for different sets of updates in a single transaction. This can +commit timestamp for different updates in a single transaction. This can be done by calling WT_SESSION::timestamp_transaction repeatedly to set a new commit timestamp between a set of updates for the current transaction. This gives the ability to commit updates with different read "as of" timestamps in a diff --git a/src/third_party/wiredtiger/src/docs/upgrading.dox b/src/third_party/wiredtiger/src/docs/upgrading.dox index 0d8e5e1b428..3428e2781d9 100644 --- a/src/third_party/wiredtiger/src/docs/upgrading.dox +++ b/src/third_party/wiredtiger/src/docs/upgrading.dox @@ -4,6 +4,14 @@ @section version_311 Upgrading to Version 3.1.1 <dl> +<dt>WiredTiger timestamps</dt> +<dd> +In previous releases of WiredTiger, it was possible to disable timestamp +support as well as to configure a timestamp size different from the 64-bit +default, using the <code>--with-timestamp-size=X</code> configuration option. +That is no longer the case, in the 3.1.1 release, timestamps are always +configured, and are always 64-bit unsigned integers. + <dt>WT_CURSOR::modify transaction requirements</dt> <dd> In previous releases of WiredTiger, it was possible to use implicit diff --git a/src/third_party/wiredtiger/src/evict/evict_lru.c b/src/third_party/wiredtiger/src/evict/evict_lru.c index 59b568aab5c..776c10d03e9 100644 --- a/src/third_party/wiredtiger/src/evict/evict_lru.c +++ b/src/third_party/wiredtiger/src/evict/evict_lru.c @@ -1957,7 +1957,7 @@ __evict_walk_tree(WT_SESSION_IMPL *session, !WT_PAGE_IS_INTERNAL(page) && !modified && page->modify != NULL && !__wt_txn_visible_all(session, page->modify->rec_max_txn, - WT_TIMESTAMP_NULL(&page->modify->rec_max_timestamp))) { + page->modify->rec_max_timestamp)) { __wt_page_modify_set(session, page); goto fast; } diff --git a/src/third_party/wiredtiger/src/evict/evict_page.c b/src/third_party/wiredtiger/src/evict/evict_page.c index 05bda7b3b14..f5765cc4313 100644 --- a/src/third_party/wiredtiger/src/evict/evict_page.c +++ b/src/third_party/wiredtiger/src/evict/evict_page.c @@ -316,7 +316,7 @@ __evict_page_clean_update(WT_SESSION_IMPL *session, WT_REF *ref, bool closing) F_ISSET(session->dhandle, WT_DHANDLE_DEAD) || (ref->page_las != NULL && ref->page_las->eviction_to_lookaside) || __wt_txn_visible_all(session, ref->page->modify->rec_max_txn, - WT_TIMESTAMP_NULL(&ref->page->modify->rec_max_timestamp))); + ref->page->modify->rec_max_timestamp)); /* * Discard the page and update the reference structure. If evicting a @@ -669,7 +669,7 @@ __evict_review( */ if (WT_SESSION_BTREE_SYNC(session) && !__wt_page_is_modified(page) && !__wt_txn_visible_all(session, page->modify->rec_max_txn, - WT_TIMESTAMP_NULL(&page->modify->rec_max_timestamp))) + page->modify->rec_max_timestamp)) return (__wt_set_return(session, EBUSY)); /* diff --git a/src/third_party/wiredtiger/src/include/btmem.h b/src/third_party/wiredtiger/src/include/btmem.h index 65ec0b3b816..b9b66bf0c7b 100644 --- a/src/third_party/wiredtiger/src/include/btmem.h +++ b/src/third_party/wiredtiger/src/include/btmem.h @@ -223,7 +223,7 @@ struct __wt_ovfl_reuse { #endif #define WT_LAS_CONFIG \ "key_format=" WT_UNCHECKED_STRING(QIQu) \ - ",value_format=" WT_UNCHECKED_STRING(QuBBu) \ + ",value_format=" WT_UNCHECKED_STRING(QQBBu) \ ",block_compressor=" WT_LOOKASIDE_COMPRESSOR \ ",leaf_value_max=64MB" \ ",prefix_compression=true" @@ -236,8 +236,8 @@ struct __wt_page_lookaside { uint64_t las_pageid; /* Page ID in lookaside */ uint64_t max_txn; /* Maximum transaction ID */ uint64_t unstable_txn; /* First transaction ID not on page */ - WT_DECL_TIMESTAMP(max_timestamp)/* Maximum timestamp */ - WT_DECL_TIMESTAMP(unstable_timestamp)/* First timestamp not on page */ + wt_timestamp_t max_timestamp; /* Maximum timestamp */ + wt_timestamp_t unstable_timestamp;/* First timestamp not on page */ bool eviction_to_lookaside; /* Revert to lookaside on eviction */ bool has_prepares; /* One or more updates are prepared */ bool skew_newest; /* Page image has newest versions */ @@ -254,7 +254,7 @@ struct __wt_page_modify { /* The transaction state last time eviction was attempted. */ uint64_t last_evict_pass_gen; uint64_t last_eviction_id; - WT_DECL_TIMESTAMP(last_eviction_timestamp) + wt_timestamp_t last_eviction_timestamp; #ifdef HAVE_DIAGNOSTIC /* Check that transaction time moves forward. */ @@ -263,14 +263,14 @@ struct __wt_page_modify { /* Avoid checking for obsolete updates during checkpoints. */ uint64_t obsolete_check_txn; - WT_DECL_TIMESTAMP(obsolete_check_timestamp) + wt_timestamp_t obsolete_check_timestamp; /* The largest transaction seen on the page by reconciliation. */ uint64_t rec_max_txn; - WT_DECL_TIMESTAMP(rec_max_timestamp) + wt_timestamp_t rec_max_timestamp; /* Stable timestamp at last reconciliation. */ - WT_DECL_TIMESTAMP(last_stable_timestamp) + wt_timestamp_t last_stable_timestamp; /* The largest update transaction ID (approximate). */ uint64_t update_txn; @@ -818,7 +818,7 @@ struct __wt_page { */ struct __wt_page_deleted { volatile uint64_t txnid; /* Transaction ID */ - WT_DECL_TIMESTAMP(timestamp) + wt_timestamp_t timestamp; /* * The state is used for transaction prepare to manage visibility @@ -1048,9 +1048,7 @@ struct __wt_ikey { */ struct __wt_update { volatile uint64_t txnid; /* transaction ID */ -#if WT_TIMESTAMP_SIZE == 8 - WT_DECL_TIMESTAMP(timestamp) /* aligned uint64_t timestamp */ -#endif + wt_timestamp_t timestamp; /* aligned uint64_t timestamp */ WT_UPDATE *next; /* forward-linked list */ @@ -1069,10 +1067,6 @@ struct __wt_update { ((upd)->type == WT_UPDATE_STANDARD || \ (upd)->type == WT_UPDATE_TOMBSTONE) -#if WT_TIMESTAMP_SIZE != 8 - WT_DECL_TIMESTAMP(timestamp) /* unaligned uint8_t array timestamp */ -#endif - /* * The update state is used for transaction prepare to manage * visibility and transitioning update structure state safely. @@ -1091,7 +1085,7 @@ struct __wt_update { * WT_UPDATE_SIZE is the expected structure size excluding the payload data -- * we verify the build to ensure the compiler hasn't inserted padding. */ -#define WT_UPDATE_SIZE (22 + WT_TIMESTAMP_SIZE) +#define WT_UPDATE_SIZE 30 /* * The memory size of an update: include some padding because this is such a diff --git a/src/third_party/wiredtiger/src/include/btree.h b/src/third_party/wiredtiger/src/include/btree.h index e4e67ba4744..58aa69fb4e5 100644 --- a/src/third_party/wiredtiger/src/include/btree.h +++ b/src/third_party/wiredtiger/src/include/btree.h @@ -162,7 +162,7 @@ struct __wt_btree { uint64_t write_gen; /* Write generation */ uint64_t rec_max_txn; /* Maximum txn seen (clean trees) */ - WT_DECL_TIMESTAMP(rec_max_timestamp) + wt_timestamp_t rec_max_timestamp; uint64_t checkpoint_gen; /* Checkpoint generation */ WT_SESSION_IMPL *sync_session; /* Syncing session */ diff --git a/src/third_party/wiredtiger/src/include/btree.i b/src/third_party/wiredtiger/src/include/btree.i index 80797325e26..c9004138370 100644 --- a/src/third_party/wiredtiger/src/include/btree.i +++ b/src/third_party/wiredtiger/src/include/btree.i @@ -1175,9 +1175,8 @@ __wt_page_del_active(WT_SESSION_IMPL *session, WT_REF *ref, bool visible_all) return (true); return (visible_all ? !__wt_txn_visible_all(session, - page_del->txnid, WT_TIMESTAMP_NULL(&page_del->timestamp)) : - !__wt_txn_visible(session, - page_del->txnid, WT_TIMESTAMP_NULL(&page_del->timestamp))); + page_del->txnid, page_del->timestamp) : + !__wt_txn_visible(session, page_del->txnid, page_del->timestamp)); } /* @@ -1194,7 +1193,7 @@ __wt_page_las_active(WT_SESSION_IMPL *session, WT_REF *ref) if (!page_las->skew_newest || page_las->has_prepares) return (true); if (__wt_txn_visible_all(session, page_las->max_txn, - WT_TIMESTAMP_NULL(&page_las->max_timestamp))) + page_las->max_timestamp)) return (false); return (true); @@ -1337,9 +1336,9 @@ __wt_leaf_page_can_split(WT_SESSION_IMPL *session, WT_PAGE *page) static inline bool __wt_page_evict_retry(WT_SESSION_IMPL *session, WT_PAGE *page) { - WT_DECL_TIMESTAMP(pinned_ts) WT_PAGE_MODIFY *mod; WT_TXN_GLOBAL *txn_global; + wt_timestamp_t pinned_ts; txn_global = &S2C(session)->txn_global; @@ -1365,14 +1364,12 @@ __wt_page_evict_retry(WT_SESSION_IMPL *session, WT_PAGE *page) mod->last_eviction_id != __wt_txn_oldest_id(session)) return (true); -#ifdef HAVE_TIMESTAMPS - if (__wt_timestamp_iszero(&mod->last_eviction_timestamp)) + if (mod->last_eviction_timestamp == 0) return (true); __wt_txn_pinned_timestamp(session, &pinned_ts); - if (__wt_timestamp_cmp(&pinned_ts, &mod->last_eviction_timestamp) > 0) + if (pinned_ts > mod->last_eviction_timestamp) return (true); -#endif return (false); } @@ -1459,7 +1456,7 @@ __wt_page_can_evict(WT_SESSION_IMPL *session, WT_REF *ref, bool *inmem_splitp) * evict, skip it. */ if (!modified && !__wt_txn_visible_all(session, - mod->rec_max_txn, WT_TIMESTAMP_NULL(&mod->rec_max_timestamp))) + mod->rec_max_txn, mod->rec_max_timestamp)) return (false); return (true); diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h index 5fd50cff29b..ca7f0597f88 100644 --- a/src/third_party/wiredtiger/src/include/extern.h +++ b/src/third_party/wiredtiger/src/include/extern.h @@ -845,14 +845,14 @@ 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 void __wt_timestamp_to_hex_string(char *hex_timestamp, wt_timestamp_t ts); +extern void __wt_verbose_timestamp(WT_SESSION_IMPL *session, wt_timestamp_t ts, const char *msg); extern int __wt_txn_parse_timestamp_raw(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_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_query_timestamp(WT_SESSION_IMPL *session, char *hex_timestamp, const char *cfg[], bool global_txn) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_update_pinned_timestamp(WT_SESSION_IMPL *session, bool force) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_global_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_timestamp_validate(WT_SESSION_IMPL *session, const char *name, wt_timestamp_t *ts, WT_CONFIG_ITEM *cval) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_timestamp_validate(WT_SESSION_IMPL *session, const char *name, wt_timestamp_t ts, WT_CONFIG_ITEM *cval) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_parse_prepare_timestamp(WT_SESSION_IMPL *session, const char *cfg[], wt_timestamp_t *timestamp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_parse_read_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); diff --git a/src/third_party/wiredtiger/src/include/lsm.h b/src/third_party/wiredtiger/src/include/lsm.h index 67ef28757ef..0945edb81a0 100644 --- a/src/third_party/wiredtiger/src/include/lsm.h +++ b/src/third_party/wiredtiger/src/include/lsm.h @@ -98,7 +98,7 @@ struct __wt_lsm_chunk { * out, or by compact to get the most * recent chunk flushed. */ - WT_DECL_TIMESTAMP(switch_timestamp)/* + wt_timestamp_t switch_timestamp;/* * The timestamp used to decide when * updates need to detect conflicts. */ diff --git a/src/third_party/wiredtiger/src/include/misc.h b/src/third_party/wiredtiger/src/include/misc.h index 9e2108a6be2..9e9fc15fb52 100644 --- a/src/third_party/wiredtiger/src/include/misc.h +++ b/src/third_party/wiredtiger/src/include/misc.h @@ -273,30 +273,6 @@ (dst).size = (src).size; \ } while (0) -/* Timestamp type and helper macros. */ -#if WT_TIMESTAMP_SIZE > 0 -#define HAVE_TIMESTAMPS -#else -#undef HAVE_TIMESTAMPS -#endif - -#ifdef HAVE_TIMESTAMPS -struct __wt_timestamp_t { -#if WT_TIMESTAMP_SIZE == 8 - uint64_t val; -#else - uint8_t ts[WT_TIMESTAMP_SIZE]; -#endif -}; -typedef struct __wt_timestamp_t wt_timestamp_t; -#define WT_DECL_TIMESTAMP(x) wt_timestamp_t x; -#define WT_TIMESTAMP_NULL(x) (x) -#else -typedef void wt_timestamp_t; -#define WT_DECL_TIMESTAMP(x) -#define WT_TIMESTAMP_NULL(x) (NULL) -#endif - /* * In diagnostic mode we track the locations from which hazard pointers and * scratch buffers were acquired. diff --git a/src/third_party/wiredtiger/src/include/misc.i b/src/third_party/wiredtiger/src/include/misc.i index 4a34b5211d8..7142fc26817 100644 --- a/src/third_party/wiredtiger/src/include/misc.i +++ b/src/third_party/wiredtiger/src/include/misc.i @@ -195,14 +195,10 @@ __wt_snprintf_len_incr( static inline int __wt_txn_context_prepare_check(WT_SESSION_IMPL *session) { -#ifdef HAVE_TIMESTAMPS if (F_ISSET(&session->txn, WT_TXN_PREPARE)) WT_RET_MSG(session, EINVAL, "%s: not permitted in a prepared transaction", session->name); -#else - WT_UNUSED(session); -#endif return (0); } diff --git a/src/third_party/wiredtiger/src/include/serial.i b/src/third_party/wiredtiger/src/include/serial.i index 02f15cdb8af..21966dfab79 100644 --- a/src/third_party/wiredtiger/src/include/serial.i +++ b/src/third_party/wiredtiger/src/include/serial.i @@ -265,7 +265,7 @@ __wt_update_serial(WT_SESSION_IMPL *session, WT_PAGE *page, { WT_DECL_RET; WT_UPDATE *obsolete, *upd; - wt_timestamp_t *obsolete_timestamp; + wt_timestamp_t obsolete_timestamp; size_t size; uint64_t txn; @@ -314,8 +314,7 @@ __wt_update_serial(WT_SESSION_IMPL *session, WT_PAGE *page, * is used as an indicator of there being further updates on this page. */ if ((txn = page->modify->obsolete_check_txn) != WT_TXN_NONE) { - obsolete_timestamp = - WT_TIMESTAMP_NULL(&page->modify->obsolete_check_timestamp); + obsolete_timestamp = page->modify->obsolete_check_timestamp; if (!__wt_txn_visible_all(session, txn, obsolete_timestamp)) { /* Try to move the oldest ID forward and re-check. */ WT_RET(__wt_txn_update_oldest(session, 0)); diff --git a/src/third_party/wiredtiger/src/include/stat.h b/src/third_party/wiredtiger/src/include/stat.h index 27c3099c38f..3714d03d1ce 100644 --- a/src/third_party/wiredtiger/src/include/stat.h +++ b/src/third_party/wiredtiger/src/include/stat.h @@ -851,12 +851,12 @@ struct __wt_join_stats { #define WT_SESSION_STATS_BASE 4000 struct __wt_session_stats { int64_t bytes_read; - int64_t bytes_written; - int64_t handle_lock_wait; + int64_t bytes_write; + int64_t lock_dhandle_wait; int64_t read_time; int64_t write_time; - int64_t schema_lock_wait; - int64_t cache_full_wait; + int64_t lock_schema_wait; + int64_t cache_time; }; /* Statistics section: END */ diff --git a/src/third_party/wiredtiger/src/include/txn.h b/src/third_party/wiredtiger/src/include/txn.h index c8ff4ec8cdb..8d093a81588 100644 --- a/src/third_party/wiredtiger/src/include/txn.h +++ b/src/third_party/wiredtiger/src/include/txn.h @@ -41,6 +41,10 @@ #define WT_SESSION_IS_CHECKPOINT(s) \ ((s)->id != 0 && (s)->id == S2C(s)->txn_global.checkpoint_id) +#define WT_TS_NONE 0 /* No timestamp */ + /* Bytes to hold a hex timestamp */ +#define WT_TS_HEX_SIZE (2 * sizeof(wt_timestamp_t) + 1) + /* * Perform an operation at the specified isolation level. * @@ -101,13 +105,13 @@ struct __wt_txn_global { */ volatile uint64_t oldest_id; - WT_DECL_TIMESTAMP(commit_timestamp) - WT_DECL_TIMESTAMP(last_ckpt_timestamp) - WT_DECL_TIMESTAMP(meta_ckpt_timestamp) - WT_DECL_TIMESTAMP(oldest_timestamp) - WT_DECL_TIMESTAMP(pinned_timestamp) - WT_DECL_TIMESTAMP(recovery_timestamp) - WT_DECL_TIMESTAMP(stable_timestamp) + wt_timestamp_t commit_timestamp; + wt_timestamp_t last_ckpt_timestamp; + wt_timestamp_t meta_ckpt_timestamp; + wt_timestamp_t oldest_timestamp; + wt_timestamp_t pinned_timestamp; + wt_timestamp_t recovery_timestamp; + wt_timestamp_t stable_timestamp; bool has_commit_timestamp; bool has_oldest_timestamp; bool has_pinned_timestamp; @@ -147,7 +151,7 @@ struct __wt_txn_global { volatile bool checkpoint_running; /* Checkpoint running */ volatile uint32_t checkpoint_id; /* Checkpoint's session ID */ WT_TXN_STATE checkpoint_state; /* Checkpoint's txn state */ - WT_DECL_TIMESTAMP(checkpoint_timestamp) /* Checkpoint's timestamp */ + wt_timestamp_t checkpoint_timestamp; /* Checkpoint's timestamp */ volatile uint64_t metadata_pinned; /* Oldest ID for metadata */ @@ -249,22 +253,22 @@ struct __wt_txn { * In some use cases, this can be updated while the transaction is * running. */ - WT_DECL_TIMESTAMP(commit_timestamp) + wt_timestamp_t commit_timestamp; /* * Set to the first commit timestamp used in the transaction and fixed * while the transaction is on the public list of committed timestamps. */ - WT_DECL_TIMESTAMP(first_commit_timestamp) + wt_timestamp_t first_commit_timestamp; /* * Timestamp copied into updates created by this transaction, when this * transaction is prepared. */ - WT_DECL_TIMESTAMP(prepare_timestamp) + wt_timestamp_t prepare_timestamp; /* Read updates committed as of this timestamp. */ - WT_DECL_TIMESTAMP(read_timestamp) + wt_timestamp_t read_timestamp; TAILQ_ENTRY(__wt_txn) commit_timestampq; TAILQ_ENTRY(__wt_txn) read_timestampq; diff --git a/src/third_party/wiredtiger/src/include/txn.i b/src/third_party/wiredtiger/src/include/txn.i index 84cd0c27ef6..7de59e498d4 100644 --- a/src/third_party/wiredtiger/src/include/txn.i +++ b/src/third_party/wiredtiger/src/include/txn.i @@ -14,7 +14,7 @@ typedef enum { WT_VISIBLE_PREPARE=1, /* Prepared update */ WT_VISIBLE_TRUE=2 /* A visible update */ } WT_VISIBLE_TYPE; -#ifdef HAVE_TIMESTAMPS + /* * __wt_txn_timestamp_flags -- * Set transaction related timestamp flags. @@ -37,162 +37,6 @@ __wt_txn_timestamp_flags(WT_SESSION_IMPL *session) F_SET(&session->txn, WT_TXN_TS_COMMIT_NEVER); } -#if WT_TIMESTAMP_SIZE == 8 -#define WT_WITH_TIMESTAMP_READLOCK(session, l, e) e - -/* - * __wt_timestamp_cmp -- - * Compare two timestamps. - */ -static inline int -__wt_timestamp_cmp(const wt_timestamp_t *ts1, const wt_timestamp_t *ts2) -{ - return (ts1->val == ts2->val ? 0 : (ts1->val > ts2->val ? 1 : -1)); -} - -/* - * __wt_timestamp_set -- - * Set a timestamp. - */ -static inline void -__wt_timestamp_set(wt_timestamp_t *dest, const wt_timestamp_t *src) -{ - dest->val = src->val; -} - -/* - * __wt_timestamp_subone -- - * Subtract one from a timestamp. - */ -static inline void -__wt_timestamp_subone(wt_timestamp_t *ts) -{ - ts->val -= 1; -} - -/* - * __wt_timestamp_iszero -- - * Check if a timestamp is equal to the special "zero" time. - */ -static inline bool -__wt_timestamp_iszero(const wt_timestamp_t *ts) -{ - return (ts->val == 0); -} - -/* - * __wt_timestamp_set_inf -- - * Set a timestamp to the maximum value. - */ -static inline void -__wt_timestamp_set_inf(wt_timestamp_t *ts) -{ - ts->val = UINT64_MAX; -} - -/* - * __wt_timestamp_set_zero -- - * Zero out a timestamp. - */ -static inline void -__wt_timestamp_set_zero(wt_timestamp_t *ts) -{ - ts->val = 0; -} - -#else /* WT_TIMESTAMP_SIZE != 8 */ - -#define WT_WITH_TIMESTAMP_READLOCK(s, l, e) do { \ - __wt_readlock((s), (l)); \ - e; \ - __wt_readunlock((s), (l)); \ -} while (0) - -/* - * __wt_timestamp_cmp -- - * Compare two timestamps. - */ -static inline int -__wt_timestamp_cmp(const wt_timestamp_t *ts1, const wt_timestamp_t *ts2) -{ - return (memcmp(ts1->ts, ts2->ts, WT_TIMESTAMP_SIZE)); -} - -/* - * __wt_timestamp_set -- - * Set a timestamp. - */ -static inline void -__wt_timestamp_set(wt_timestamp_t *dest, const wt_timestamp_t *src) -{ - (void)memcpy(dest->ts, src->ts, WT_TIMESTAMP_SIZE); -} - -/* - * __wt_timestamp_iszero -- - * Check if a timestamp is equal to the special "zero" time. - */ -static inline bool -__wt_timestamp_iszero(const wt_timestamp_t *ts) -{ - static const wt_timestamp_t zero_timestamp; - - return (memcmp(ts->ts, &zero_timestamp, WT_TIMESTAMP_SIZE) == 0); -} - -/* - * __wt_timestamp_set_inf -- - * Set a timestamp to the maximum value. - */ -static inline void -__wt_timestamp_set_inf(wt_timestamp_t *ts) -{ - memset(ts->ts, 0xff, WT_TIMESTAMP_SIZE); -} - -/* - * __wt_timestamp_set_zero -- - * Zero out a timestamp. - */ -static inline void -__wt_timestamp_set_zero(wt_timestamp_t *ts) -{ - memset(ts->ts, 0x00, WT_TIMESTAMP_SIZE); -} - -/* - * __wt_timestamp_subone -- - * Subtract one from a timestamp. - */ -static inline void -__wt_timestamp_subone(wt_timestamp_t *ts) -{ - uint8_t *tsb; - - /* - * Complicated path for arbitrary-sized timestamps: start with the - * least significant byte, subtract one, continue to more significant - * bytes on underflow. - */ - for (tsb = ts->ts + WT_TIMESTAMP_SIZE - 1; tsb >= ts->ts; --tsb) - if (--*tsb != 0xff) - break; -} - -#endif /* WT_TIMESTAMP_SIZE == 8 */ - -#else /* !HAVE_TIMESTAMPS */ - -#define __wt_timestamp_set(dest, src) -#define __wt_timestamp_set_inf(ts) -#define __wt_timestamp_set_zero(ts) -#define __wt_timestamp_subone(ts) -#define __wt_txn_clear_commit_timestamp(session) -#define __wt_txn_clear_read_timestamp(session) -#define __wt_txn_timestamp_flags(session) - -#endif /* HAVE_TIMESTAMPS */ - /* * __wt_txn_op_set_recno -- * Set the latest transaction operation with the given recno. @@ -271,7 +115,6 @@ __wt_txn_op_set_key(WT_SESSION_IMPL *session, const WT_ITEM *key) static inline void __txn_resolve_prepared_update(WT_SESSION_IMPL *session, WT_UPDATE *upd) { -#ifdef HAVE_TIMESTAMPS WT_TXN *txn; txn = &session->txn; @@ -286,12 +129,8 @@ __txn_resolve_prepared_update(WT_SESSION_IMPL *session, WT_UPDATE *upd) */ upd->prepare_state = WT_PREPARE_LOCKED; WT_WRITE_BARRIER(); - __wt_timestamp_set(&upd->timestamp, &txn->commit_timestamp); + upd->timestamp = txn->commit_timestamp; WT_PUBLISH(upd->prepare_state, WT_PREPARE_RESOLVED); -#else - WT_UNUSED(session); - WT_UNUSED(upd); -#endif } /* @@ -503,7 +342,6 @@ __wt_txn_unmodify(WT_SESSION_IMPL *session) } } -#ifdef HAVE_TIMESTAMPS /* * __wt_txn_op_commit_page_del -- * Make the transaction ID and timestamp updates necessary to a ref that @@ -536,7 +374,7 @@ __wt_txn_op_commit_page_del(WT_SESSION_IMPL *session, WT_REF *ref) for (updp = ref->page_del->update_list; updp != NULL && *updp != NULL; ++updp) { - __wt_timestamp_set(&(*updp)->timestamp, &txn->commit_timestamp); + (*updp)->timestamp = txn->commit_timestamp; if (F_ISSET(txn, WT_TXN_PREPARE)) /* * Holding the ref locked means we have exclusive @@ -593,11 +431,10 @@ __wt_txn_op_set_timestamp(WT_SESSION_IMPL *session, WT_TXN_OP *op) */ timestamp = op->type == WT_TXN_OP_REF_DELETE ? &op->u.ref->page_del->timestamp : &op->u.op_upd->timestamp; - if (__wt_timestamp_iszero(timestamp)) - __wt_timestamp_set(timestamp, &txn->commit_timestamp); + if (*timestamp == 0) + *timestamp = txn->commit_timestamp; } } -#endif /* * __wt_txn_modify -- @@ -630,10 +467,7 @@ __wt_txn_modify(WT_SESSION_IMPL *session, WT_UPDATE *upd) op->u.op_upd = upd; upd->txnid = session->txn.id; -#ifdef HAVE_TIMESTAMPS __wt_txn_op_set_timestamp(session, op); -#endif - return (0); } @@ -655,9 +489,7 @@ __wt_txn_modify_page_delete(WT_SESSION_IMPL *session, WT_REF *ref) op->u.ref = ref; ref->page_del->txnid = txn->id; -#ifdef HAVE_TIMESTAMPS __wt_txn_op_set_timestamp(session, op); -#endif WT_ERR(__wt_txn_log_op(session, NULL)); return (0); @@ -726,7 +558,6 @@ __wt_txn_oldest_id(WT_SESSION_IMPL *session) return (checkpoint_pinned); } -#ifdef HAVE_TIMESTAMPS /* * __wt_txn_pinned_timestamp -- * Get the first timestamp that has to be kept for the current tree. @@ -742,9 +573,7 @@ __wt_txn_pinned_timestamp(WT_SESSION_IMPL *session, wt_timestamp_t *pinned_tsp) btree = S2BT_SAFE(session); txn_global = &S2C(session)->txn_global; - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - __wt_timestamp_set(&pinned_ts, &txn_global->pinned_timestamp)); - __wt_timestamp_set(pinned_tsp, &pinned_ts); + *pinned_tsp = pinned_ts = txn_global->pinned_timestamp; /* * Checkpoint transactions often fall behind ordinary application @@ -770,15 +599,11 @@ __wt_txn_pinned_timestamp(WT_SESSION_IMPL *session, wt_timestamp_t *pinned_tsp) */ WT_READ_BARRIER(); - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - __wt_timestamp_set(&checkpoint_ts, - &txn_global->checkpoint_timestamp)); + checkpoint_ts = txn_global->checkpoint_timestamp; - if (!__wt_timestamp_iszero(&checkpoint_ts) && - __wt_timestamp_cmp(&checkpoint_ts, &pinned_ts) < 0) - __wt_timestamp_set(pinned_tsp, &checkpoint_ts); + if (checkpoint_ts != 0 && checkpoint_ts < pinned_ts) + *pinned_tsp = checkpoint_ts; } -#endif /* * __txn_visible_all_id -- @@ -804,17 +629,15 @@ __txn_visible_all_id(WT_SESSION_IMPL *session, uint64_t id) */ static inline bool __wt_txn_visible_all( - WT_SESSION_IMPL *session, uint64_t id, const wt_timestamp_t *timestamp) + WT_SESSION_IMPL *session, uint64_t id, const wt_timestamp_t timestamp) { + wt_timestamp_t pinned_ts; + if (!__txn_visible_all_id(session, id)) return (false); -#ifdef HAVE_TIMESTAMPS - { - wt_timestamp_t pinned_ts; - /* Timestamp check. */ - if (timestamp == NULL || __wt_timestamp_iszero(timestamp)) + if (timestamp == WT_TS_NONE) return (true); /* @@ -825,12 +648,7 @@ __wt_txn_visible_all( return (F_ISSET(S2C(session), WT_CONN_CLOSING)); __wt_txn_pinned_timestamp(session, &pinned_ts); - return (__wt_timestamp_cmp(timestamp, &pinned_ts) <= 0); - } -#else - WT_UNUSED(timestamp); - return (true); -#endif + return (timestamp <= pinned_ts); } /* @@ -844,8 +662,7 @@ __wt_txn_upd_visible_all(WT_SESSION_IMPL *session, WT_UPDATE *upd) upd->prepare_state == WT_PREPARE_INPROGRESS) return (false); - return (__wt_txn_visible_all( - session, upd->txnid, WT_TIMESTAMP_NULL(&upd->timestamp))); + return (__wt_txn_visible_all(session, upd->txnid, upd->timestamp)); } /* @@ -907,8 +724,12 @@ __txn_visible_id(WT_SESSION_IMPL *session, uint64_t id) */ static inline bool __wt_txn_visible( - WT_SESSION_IMPL *session, uint64_t id, const wt_timestamp_t *timestamp) + WT_SESSION_IMPL *session, uint64_t id, const wt_timestamp_t timestamp) { + WT_TXN *txn; + + txn = &session->txn; + if (!__txn_visible_id(session, id)) return (false); @@ -916,20 +737,11 @@ __wt_txn_visible( if (F_ISSET(&session->txn, WT_TXN_HAS_ID) && id == session->txn.id) return (true); -#ifdef HAVE_TIMESTAMPS - { - WT_TXN *txn = &session->txn; - /* Timestamp check. */ - if (!F_ISSET(txn, WT_TXN_HAS_TS_READ) || timestamp == NULL) + if (!F_ISSET(txn, WT_TXN_HAS_TS_READ) || timestamp == WT_TS_NONE) return (true); - return (__wt_timestamp_cmp(timestamp, &txn->read_timestamp) <= 0); - } -#else - WT_UNUSED(timestamp); - return (true); -#endif + return (timestamp <= txn->read_timestamp); } /* @@ -949,7 +761,7 @@ __wt_txn_upd_visible_type(WT_SESSION_IMPL *session, WT_UPDATE *upd) continue; upd_visible = __wt_txn_visible( - session, upd->txnid, WT_TIMESTAMP_NULL(&upd->timestamp)); + session, upd->txnid, upd->timestamp); /* * The visibility check is only valid if the update does not @@ -1196,7 +1008,6 @@ __wt_txn_id_check(WT_SESSION_IMPL *session) static inline int __wt_txn_search_check(WT_SESSION_IMPL *session) { -#ifdef HAVE_TIMESTAMPS WT_BTREE *btree; WT_TXN *txn; @@ -1215,8 +1026,6 @@ __wt_txn_search_check(WT_SESSION_IMPL *session) F_ISSET(txn, WT_TXN_PUBLIC_TS_READ)) WT_RET_MSG(session, EINVAL, "no read_timestamp required and " "timestamp set on this transaction"); -#endif - WT_UNUSED(session); return (0); } diff --git a/src/third_party/wiredtiger/src/include/wiredtiger.in b/src/third_party/wiredtiger/src/include/wiredtiger.in index 551491a1617..f04ad40693e 100644 --- a/src/third_party/wiredtiger/src/include/wiredtiger.in +++ b/src/third_party/wiredtiger/src/include/wiredtiger.in @@ -1902,8 +1902,7 @@ struct __wt_session { * @param session the session handle * @param[out] hex_timestamp a buffer that will be set to the * hexadecimal encoding of the timestamp being queried. Must be large - * enough to hold a hex-encoded timestamp (i.e., double the timestamp - * size plus one byte for NUL termination). + * enough to hold a NUL terminated, hex-encoded 8B timestamp (17 bytes). * @configstart{WT_SESSION.query_timestamp, see dist/api_data.py} * @config{get, specify which timestamp to query: \c commit returns the * most recently set commit_timestamp. \c first_commit returns the @@ -2481,8 +2480,7 @@ struct __wt_connection { * @param connection the connection handle * @param[out] hex_timestamp a buffer that will be set to the * hexadecimal encoding of the timestamp being queried. Must be large - * enough to hold a hex-encoded timestamp (i.e., double the timestamp - * size plus one byte for NUL termination). + * enough to hold a NUL terminated, hex-encoded 8B timestamp (17 bytes). * @configstart{WT_CONNECTION.query_timestamp, see dist/api_data.py} * @config{get, specify which timestamp to query: \c all_committed * returns the largest timestamp such that all timestamps up to that @@ -6207,17 +6205,17 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection); /*! session: bytes read into cache */ #define WT_STAT_SESSION_BYTES_READ 4000 /*! session: bytes written from cache */ -#define WT_STAT_SESSION_BYTES_WRITTEN 4001 -/*! session: handle lock wait time (usecs) */ -#define WT_STAT_SESSION_HANDLE_LOCK_WAIT 4002 +#define WT_STAT_SESSION_BYTES_WRITE 4001 +/*! session: dhandle lock wait time (usecs) */ +#define WT_STAT_SESSION_LOCK_DHANDLE_WAIT 4002 /*! session: page read from disk to cache time (usecs) */ #define WT_STAT_SESSION_READ_TIME 4003 /*! session: page write from cache to disk time (usecs) */ #define WT_STAT_SESSION_WRITE_TIME 4004 /*! session: schema lock wait time (usecs) */ -#define WT_STAT_SESSION_SCHEMA_LOCK_WAIT 4005 +#define WT_STAT_SESSION_LOCK_SCHEMA_WAIT 4005 /*! session: time waiting for cache (usecs) */ -#define WT_STAT_SESSION_CACHE_FULL_WAIT 4006 +#define WT_STAT_SESSION_CACHE_TIME 4006 /*! @} */ /* * Statistics section: END diff --git a/src/third_party/wiredtiger/src/include/wt_internal.h b/src/third_party/wiredtiger/src/include/wt_internal.h index 365d1370e44..bea08bb27cc 100644 --- a/src/third_party/wiredtiger/src/include/wt_internal.h +++ b/src/third_party/wiredtiger/src/include/wt_internal.h @@ -301,8 +301,6 @@ struct __wt_thread; typedef struct __wt_thread WT_THREAD; struct __wt_thread_group; typedef struct __wt_thread_group WT_THREAD_GROUP; -struct __wt_timestamp_t; - typedef struct __wt_timestamp_t WT_TIMESTAMP_T; struct __wt_txn; typedef struct __wt_txn WT_TXN; struct __wt_txn_global; @@ -319,6 +317,9 @@ union __wt_lsn; typedef union __wt_lsn WT_LSN; union __wt_rand_state; typedef union __wt_rand_state WT_RAND_STATE; + +typedef uint64_t wt_timestamp_t; + /* * Forward type declarations for internal types: END * DO NOT EDIT: automatically built by dist/s_typedef. diff --git a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c index 5dd3122d41c..0a0bf373341 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c @@ -240,7 +240,7 @@ __clsm_enter(WT_CURSOR_LSM *clsm, bool reset, bool update) break; WT_ASSERT(session, !__wt_txn_visible_all( - session, switch_txn, NULL)); + session, switch_txn, WT_TS_NONE)); } } } @@ -1500,7 +1500,7 @@ __clsm_put(WT_SESSION_IMPL *session, WT_CURSOR_LSM *clsm, for (i = 0, slot = clsm->nchunks - 1; i < clsm->nupdates; i++, slot--) { /* Check if we need to keep updating old chunks. */ if (i > 0 && __wt_txn_visible( - session, clsm->chunks[slot]->switch_txn, NULL)) { + session, clsm->chunks[slot]->switch_txn, WT_TS_NONE)) { clsm->nupdates = i; break; } diff --git a/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c b/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c index a283670eba6..98645456fc4 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c @@ -264,20 +264,18 @@ bool __wt_lsm_chunk_visible_all( WT_SESSION_IMPL *session, WT_LSM_CHUNK *chunk) { + WT_TXN_GLOBAL *txn_global; + + txn_global = &S2C(session)->txn_global; + /* Once a chunk has been flushed it's contents must be visible */ if (F_ISSET(chunk, WT_LSM_CHUNK_ONDISK | WT_LSM_CHUNK_STABLE)) return (true); if (chunk->switch_txn == WT_TXN_NONE || - !__wt_txn_visible_all(session, chunk->switch_txn, NULL)) + !__wt_txn_visible_all(session, chunk->switch_txn, WT_TS_NONE)) return (false); -#ifdef HAVE_TIMESTAMPS - { - WT_TXN_GLOBAL *txn_global; - - txn_global = &S2C(session)->txn_global; - /* * Once all transactions with updates in the chunk are visible all * timestamps associated with those updates are assigned so setup a @@ -290,15 +288,15 @@ __wt_lsm_chunk_visible_all( /* Set the timestamp if we won the race */ if (!F_ISSET(chunk, WT_LSM_CHUNK_HAS_TIMESTAMP)) { __wt_readlock(session, &txn_global->rwlock); - __wt_timestamp_set(&chunk->switch_timestamp, - &txn_global->commit_timestamp); + chunk->switch_timestamp = + txn_global->commit_timestamp; __wt_readunlock(session, &txn_global->rwlock); F_SET(chunk, WT_LSM_CHUNK_HAS_TIMESTAMP); } __wt_spin_unlock(session, &chunk->timestamp_spinlock); } if (!__wt_txn_visible_all( - session, chunk->switch_txn, &chunk->switch_timestamp)) + session, chunk->switch_txn, chunk->switch_timestamp)) return (false); } else /* @@ -307,8 +305,7 @@ __wt_lsm_chunk_visible_all( * there could be confusion if timestamps start being used. */ F_SET(chunk, WT_LSM_CHUNK_HAS_TIMESTAMP); - } -#endif + return (true); } diff --git a/src/third_party/wiredtiger/src/meta/meta_ckpt.c b/src/third_party/wiredtiger/src/meta/meta_ckpt.c index 13e84efc199..2703ff018b6 100644 --- a/src/third_party/wiredtiger/src/meta/meta_ckpt.c +++ b/src/third_party/wiredtiger/src/meta/meta_ckpt.c @@ -502,20 +502,19 @@ __wt_meta_sysinfo_set(WT_SESSION_IMPL *session) { WT_DECL_ITEM(buf); WT_DECL_RET; - char hex_timestamp[2 * WT_TIMESTAMP_SIZE + 2]; + char hex_timestamp[2 * sizeof(wt_timestamp_t) + 2]; WT_ERR(__wt_scr_alloc(session, 0, &buf)); hex_timestamp[0] = '0'; hex_timestamp[1] = '\0'; -#ifdef HAVE_TIMESTAMPS + /* * We need to record the timestamp of the checkpoint in the metadata. * The timestamp value is set at a higher level, either in checkpoint * or in recovery. */ - WT_ERR(__wt_timestamp_to_hex_string(session, hex_timestamp, - &S2C(session)->txn_global.meta_ckpt_timestamp)); -#endif + __wt_timestamp_to_hex_string( + hex_timestamp, S2C(session)->txn_global.meta_ckpt_timestamp); /* * Don't leave a zero entry in the metadata: remove it. This avoids diff --git a/src/third_party/wiredtiger/src/reconcile/rec_write.c b/src/third_party/wiredtiger/src/reconcile/rec_write.c index eb0c166c44c..d3caa23ed02 100644 --- a/src/third_party/wiredtiger/src/reconcile/rec_write.c +++ b/src/third_party/wiredtiger/src/reconcile/rec_write.c @@ -47,11 +47,11 @@ typedef struct { /* Track the page's min/maximum transactions. */ uint64_t max_txn; - WT_DECL_TIMESTAMP(max_timestamp) + wt_timestamp_t max_timestamp; /* Lookaside boundary tracking. */ uint64_t unstable_txn; - WT_DECL_TIMESTAMP(unstable_timestamp) + wt_timestamp_t unstable_timestamp; u_int updates_seen; /* Count of updates seen. */ u_int updates_unstable; /* Count of updates not visible_all. */ @@ -440,11 +440,9 @@ __wt_reconcile(WT_SESSION_IMPL *session, WT_REF *ref, */ if (LF_ISSET(WT_REC_EVICT)) { mod->last_eviction_id = oldest_id; -#ifdef HAVE_TIMESTAMPS if (S2C(session)->txn_global.has_pinned_timestamp) __wt_txn_pinned_timestamp( session, &mod->last_eviction_timestamp); -#endif mod->last_evict_pass_gen = S2C(session)->cache->evict_pass_gen; } @@ -503,16 +501,12 @@ __wt_reconcile(WT_SESSION_IMPL *session, WT_REF *ref, else WT_TRET(__rec_write_wrapup_err(session, r, page)); -#ifdef HAVE_TIMESTAMPS /* * If reconciliation completes successfully, save the stable timestamp. */ if (ret == 0 && S2C(session)->txn_global.has_stable_timestamp) - WT_WITH_TIMESTAMP_READLOCK(session, - &S2C(session)->txn_global.rwlock, - __wt_timestamp_set(&mod->last_stable_timestamp, - &S2C(session)->txn_global.stable_timestamp)); -#endif + mod->last_stable_timestamp = + S2C(session)->txn_global.stable_timestamp; /* Release the reconciliation lock. */ WT_PAGE_UNLOCK(session, page); @@ -701,7 +695,7 @@ __rec_write_page_status(WT_SESSION_IMPL *session, WT_RECONCILE *r) * we can evict a clean page and discard its history). */ mod->rec_max_txn = r->max_txn; - __wt_timestamp_set(&mod->rec_max_timestamp, &r->max_timestamp); + mod->rec_max_timestamp = r->max_timestamp; /* * Track the tree's maximum transaction ID (used to decide if @@ -714,12 +708,8 @@ __rec_write_page_status(WT_SESSION_IMPL *session, WT_RECONCILE *r) if (!F_ISSET(r, WT_REC_EVICT)) { if (WT_TXNID_LT(btree->rec_max_txn, r->max_txn)) btree->rec_max_txn = r->max_txn; -#ifdef HAVE_TIMESTAMPS - if (__wt_timestamp_cmp( - &btree->rec_max_timestamp, &r->max_timestamp) < 0) - __wt_timestamp_set(&btree->rec_max_timestamp, - &r->max_timestamp); -#endif + if (btree->rec_max_timestamp < r->max_timestamp) + btree->rec_max_timestamp = r->max_timestamp; } /* @@ -951,17 +941,15 @@ __rec_init(WT_SESSION_IMPL *session, */ r->las_skew_newest = LF_ISSET(WT_REC_LOOKASIDE) && LF_ISSET(WT_REC_VISIBLE_ALL); -#ifdef HAVE_TIMESTAMPS if (r->las_skew_newest && !__wt_btree_immediately_durable(session) && txn_global->has_stable_timestamp && ((btree->checkpoint_gen != __wt_gen(session, WT_GEN_CHECKPOINT) && txn_global->stable_is_pinned) || FLD_ISSET(page->modify->restore_state, WT_PAGE_RS_LOOKASIDE) || - __wt_timestamp_cmp(&page->modify->last_stable_timestamp, - &txn_global->stable_timestamp) == 0)) + page->modify->last_stable_timestamp == + txn_global->stable_timestamp)) r->las_skew_newest = false; -#endif /* * When operating on the lookaside table, we should never try @@ -992,7 +980,7 @@ __rec_init(WT_SESSION_IMPL *session, /* Track the page's min/maximum transaction */ r->max_txn = WT_TXN_NONE; - __wt_timestamp_set_zero(&r->max_timestamp); + r->max_timestamp = 0; /* * Track the first unstable transaction (when skewing newest this is @@ -1002,10 +990,10 @@ __rec_init(WT_SESSION_IMPL *session, */ if (r->las_skew_newest) { r->unstable_txn = WT_TXN_NONE; - __wt_timestamp_set_zero(&r->unstable_timestamp); + r->unstable_timestamp = 0; } else { r->unstable_txn = WT_TXN_ABORTED; - __wt_timestamp_set_inf(&r->unstable_timestamp); + r->unstable_timestamp = UINT64_MAX; } /* Track if updates were used and/or uncommitted. */ @@ -1257,7 +1245,7 @@ __rec_append_orig_value(WT_SESSION_IMPL *session, */ if (upd->type == WT_UPDATE_BIRTHMARK) { append->txnid = upd->txnid; - __wt_timestamp_set(&append->timestamp, &upd->timestamp); + append->timestamp = upd->timestamp; append->next = upd->next; } @@ -1285,23 +1273,18 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, bool *upd_savedp, WT_UPDATE **updp) { WT_PAGE *page; - WT_UPDATE *first_txn_upd, *first_upd, *upd; - wt_timestamp_t *timestampp; + WT_UPDATE *first_ts_upd, *first_txn_upd, *first_upd, *upd; + wt_timestamp_t timestamp; size_t upd_memsize; uint64_t max_txn, txnid; bool all_visible, prepared, skipped_birthmark, uncommitted; -#ifdef HAVE_TIMESTAMPS - WT_UPDATE *first_ts_upd; - first_ts_upd = NULL; -#endif - if (upd_savedp != NULL) *upd_savedp = false; *updp = NULL; page = r->page; - first_txn_upd = NULL; + first_ts_upd = first_txn_upd = NULL; upd_memsize = 0; max_txn = WT_TXN_NONE; prepared = skipped_birthmark = uncommitted = false; @@ -1356,12 +1339,9 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, continue; } -#ifdef HAVE_TIMESTAMPS /* Track the first update with non-zero timestamp. */ - if (first_ts_upd == NULL && - !__wt_timestamp_iszero(&upd->timestamp)) + if (first_ts_upd == NULL && upd->timestamp != 0) first_ts_upd = upd; -#endif /* * Find the first update we can use. @@ -1454,12 +1434,9 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, if (WT_TXNID_LT(r->max_txn, max_txn)) r->max_txn = max_txn; -#ifdef HAVE_TIMESTAMPS /* Update the maximum timestamp. */ - if (first_ts_upd != NULL && - __wt_timestamp_cmp(&r->max_timestamp, &first_ts_upd->timestamp) < 0) - __wt_timestamp_set(&r->max_timestamp, &first_ts_upd->timestamp); -#endif + if (first_ts_upd != NULL && r->max_timestamp < first_ts_upd->timestamp) + r->max_timestamp = first_ts_upd->timestamp; /* * If the update we chose was a birthmark, or we are doing @@ -1479,15 +1456,11 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, * order), so we track the maximum transaction ID and the newest update * with a timestamp (if any). */ -#ifdef HAVE_TIMESTAMPS - timestampp = first_ts_upd == NULL ? NULL : &first_ts_upd->timestamp; -#else - timestampp = NULL; -#endif + timestamp = first_ts_upd == NULL ? 0 : first_ts_upd->timestamp; all_visible = upd == first_txn_upd && !(uncommitted || prepared) && (F_ISSET(r, WT_REC_VISIBLE_ALL) ? - __wt_txn_visible_all(session, max_txn, timestampp) : - __wt_txn_visible(session, max_txn, timestampp)); + __wt_txn_visible_all(session, max_txn, timestamp) : + __wt_txn_visible(session, max_txn, timestamp)); if (all_visible) goto check_original_value; @@ -1544,13 +1517,9 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, if (F_ISSET(r, WT_REC_LOOKASIDE) && r->las_skew_newest) { if (WT_TXNID_LT(r->unstable_txn, first_upd->txnid)) r->unstable_txn = first_upd->txnid; -#ifdef HAVE_TIMESTAMPS if (first_ts_upd != NULL && - __wt_timestamp_cmp(&r->unstable_timestamp, - &first_ts_upd->timestamp) < 0) - __wt_timestamp_set(&r->unstable_timestamp, - &first_ts_upd->timestamp); -#endif + r->unstable_timestamp < first_ts_upd->timestamp) + r->unstable_timestamp = first_ts_upd->timestamp; } else if (F_ISSET(r, WT_REC_LOOKASIDE)) { for (upd = first_upd; upd != *updp; upd = upd->next) { if (upd->txnid == WT_TXN_ABORTED) @@ -1559,12 +1528,8 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, if (upd->txnid != WT_TXN_NONE && WT_TXNID_LT(upd->txnid, r->unstable_txn)) r->unstable_txn = upd->txnid; -#ifdef HAVE_TIMESTAMPS - if (__wt_timestamp_cmp(&upd->timestamp, - &r->unstable_timestamp) < 0) - __wt_timestamp_set(&r->unstable_timestamp, - &upd->timestamp); -#endif + if (upd->timestamp < r->unstable_timestamp) + r->unstable_timestamp = upd->timestamp; } } @@ -3434,12 +3399,8 @@ done: if (F_ISSET(r, WT_REC_LOOKASIDE)) { multi->page_las.max_txn = r->max_txn; multi->page_las.unstable_txn = r->unstable_txn; WT_ASSERT(session, r->unstable_txn != WT_TXN_NONE); -#ifdef HAVE_TIMESTAMPS - __wt_timestamp_set(&multi->page_las.max_timestamp, - &r->max_timestamp); - __wt_timestamp_set(&multi->page_las.unstable_timestamp, - &r->unstable_timestamp); -#endif + multi->page_las.max_timestamp = r->max_timestamp; + multi->page_las.unstable_timestamp = r->unstable_timestamp; } err: __wt_scr_free(session, &key); diff --git a/src/third_party/wiredtiger/src/session/session_api.c b/src/third_party/wiredtiger/src/session/session_api.c index 85740d4935b..c413fb21f32 100644 --- a/src/third_party/wiredtiger/src/session/session_api.c +++ b/src/third_party/wiredtiger/src/session/session_api.c @@ -1012,6 +1012,10 @@ __session_reset(WT_SESSION *wt_session) /* Release common session resources. */ WT_TRET(__wt_session_release_resources(session)); + /* Reset the session statistics. */ + if (WT_STAT_ENABLED(session)) + __wt_stat_session_clear_single(&session->stats); + err: API_END_RET_NOTFOUND_MAP(session, ret); } diff --git a/src/third_party/wiredtiger/src/support/stat.c b/src/third_party/wiredtiger/src/support/stat.c index 0204be3aa76..a2019cd3aac 100644 --- a/src/third_party/wiredtiger/src/support/stat.c +++ b/src/third_party/wiredtiger/src/support/stat.c @@ -2160,7 +2160,7 @@ __wt_stat_join_aggregate( static const char * const __stats_session_desc[] = { "session: bytes read into cache", "session: bytes written from cache", - "session: handle lock wait time (usecs)", + "session: dhandle lock wait time (usecs)", "session: page read from disk to cache time (usecs)", "session: page write from cache to disk time (usecs)", "session: schema lock wait time (usecs)", @@ -2185,10 +2185,10 @@ void __wt_stat_session_clear_single(WT_SESSION_STATS *stats) { stats->bytes_read = 0; - stats->bytes_written = 0; - stats->handle_lock_wait = 0; + stats->bytes_write = 0; + stats->lock_dhandle_wait = 0; stats->read_time = 0; stats->write_time = 0; - stats->schema_lock_wait = 0; - stats->cache_full_wait = 0; + stats->lock_schema_wait = 0; + stats->cache_time = 0; } diff --git a/src/third_party/wiredtiger/src/txn/txn.c b/src/third_party/wiredtiger/src/txn/txn.c index 6f8c0969f40..20e469d0262 100644 --- a/src/third_party/wiredtiger/src/txn/txn.c +++ b/src/third_party/wiredtiger/src/txn/txn.c @@ -129,7 +129,7 @@ __wt_txn_release_snapshot(WT_SESSION_IMPL *session) WT_ASSERT(session, txn_state->pinned_id == WT_TXN_NONE || session->txn.isolation == WT_ISO_READ_UNCOMMITTED || - !__wt_txn_visible_all(session, txn_state->pinned_id, NULL)); + !__wt_txn_visible_all(session, txn_state->pinned_id, WT_TS_NONE)); txn_state->metadata_pinned = txn_state->pinned_id = WT_TXN_NONE; F_CLR(txn, WT_TXN_HAS_SNAPSHOT); @@ -137,7 +137,7 @@ __wt_txn_release_snapshot(WT_SESSION_IMPL *session) /* Clear a checkpoint's pinned ID. */ if (WT_SESSION_IS_CHECKPOINT(session)) { txn_global->checkpoint_state.pinned_id = WT_TXN_NONE; - __wt_timestamp_set_zero(&txn_global->checkpoint_timestamp); + txn_global->checkpoint_timestamp = 0; } __wt_txn_clear_read_timestamp(session); @@ -329,11 +329,9 @@ __wt_txn_update_oldest(WT_SESSION_IMPL *session, uint32_t flags) prev_metadata_pinned = txn_global->metadata_pinned; prev_oldest_id = txn_global->oldest_id; -#ifdef HAVE_TIMESTAMPS /* Try to move the pinned timestamp forward. */ if (strict) WT_RET(__wt_txn_update_pinned_timestamp(session, false)); -#endif /* * For pure read-only workloads, or if the update isn't forced and the @@ -577,7 +575,6 @@ __wt_txn_release(WT_SESSION_IMPL *session) txn->flags = 0; } -#ifdef HAVE_TIMESTAMPS /* * __txn_commit_timestamp_validate -- * Validate that timestamp provided to commit is legal. @@ -585,10 +582,10 @@ __wt_txn_release(WT_SESSION_IMPL *session) static inline int __txn_commit_timestamp_validate(WT_SESSION_IMPL *session) { - WT_DECL_TIMESTAMP(op_timestamp) WT_TXN *txn; WT_TXN_OP *op; WT_UPDATE *upd; + wt_timestamp_t op_timestamp; u_int i; bool op_zero_ts, upd_zero_ts; @@ -646,7 +643,7 @@ __txn_commit_timestamp_validate(WT_SESSION_IMPL *session) * Check timestamps are used in order. */ op_zero_ts = !F_ISSET(txn, WT_TXN_HAS_TS_COMMIT); - upd_zero_ts = __wt_timestamp_iszero(&upd->timestamp); + upd_zero_ts = upd->timestamp == 0; if (op_zero_ts != upd_zero_ts) WT_RET_MSG(session, EINVAL, "per-key timestamps used inconsistently"); @@ -663,16 +660,14 @@ __txn_commit_timestamp_validate(WT_SESSION_IMPL *session) * Only if the update structure doesn't have a timestamp * then use the one in the transaction structure. */ - if (__wt_timestamp_iszero(&op_timestamp)) + if (op_timestamp == 0) op_timestamp = txn->commit_timestamp; - if (__wt_timestamp_cmp(&op_timestamp, - &upd->timestamp) < 0) + if (op_timestamp < upd->timestamp) WT_RET_MSG(session, EINVAL, "out of order timestamps"); } return (0); } -#endif /* * __wt_txn_commit -- @@ -688,17 +683,15 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]) WT_TXN_GLOBAL *txn_global; WT_TXN_OP *op; WT_UPDATE *upd; + wt_timestamp_t prev_commit_timestamp, ts; uint32_t fileid; u_int i; - bool locked, prepare, readonly; -#ifdef HAVE_TIMESTAMPS - wt_timestamp_t prev_commit_timestamp, ts; - bool update_timestamp; -#endif + bool locked, prepare, readonly, update_timestamp; txn = &session->txn; conn = S2C(session); txn_global = &conn->txn_global; + prev_commit_timestamp = 0; /* -Wconditional-uninitialized */ locked = false; WT_ASSERT(session, F_ISSET(txn, WT_TXN_RUNNING)); @@ -712,15 +705,10 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]) WT_ERR( __wt_config_gets_def(session, cfg, "commit_timestamp", 0, &cval)); if (cval.len != 0) { -#ifdef HAVE_TIMESTAMPS WT_ERR(__wt_txn_parse_timestamp(session, "commit", &ts, &cval)); - WT_ERR(__wt_timestamp_validate(session, "commit", &ts, &cval)); - __wt_timestamp_set(&txn->commit_timestamp, &ts); + WT_ERR(__wt_timestamp_validate(session, "commit", ts, &cval)); + txn->commit_timestamp = ts; __wt_txn_set_commit_timestamp(session); -#else - WT_ERR_MSG(session, EINVAL, "commit_timestamp requires a " - "version of WiredTiger built with timestamp support"); -#endif } prepare = F_ISSET(txn, WT_TXN_PREPARE); @@ -728,9 +716,7 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]) WT_ERR_MSG(session, EINVAL, "commit_timestamp is required for a prepared transaction"); -#ifdef HAVE_TIMESTAMPS WT_ERR(__txn_commit_timestamp_validate(session)); -#endif /* * The default sync setting is inherited from the connection, but can @@ -848,19 +834,15 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]) break; } -#ifdef HAVE_TIMESTAMPS __wt_txn_op_set_timestamp(session, op); } else { WT_ERR(__wt_txn_resolve_prepared_op( session, op, true)); -#endif } break; case WT_TXN_OP_REF_DELETE: -#ifdef HAVE_TIMESTAMPS __wt_txn_op_set_timestamp(session, op); -#endif break; case WT_TXN_OP_TRUNCATE_COL: case WT_TXN_OP_TRUNCATE_ROW: @@ -872,7 +854,6 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]) } txn->mod_count = 0; -#ifdef HAVE_TIMESTAMPS /* * Track the largest commit timestamp we have seen. * @@ -881,7 +862,6 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]) * transaction is visible, which happens when we release it. */ update_timestamp = F_ISSET(txn, WT_TXN_HAS_TS_COMMIT); -#endif __wt_txn_release(session); if (locked) @@ -894,46 +874,26 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]) if (!readonly) (void)__wt_gen_next(session, WT_GEN_COMMIT); -#ifdef HAVE_TIMESTAMPS /* First check if we've already committed something in the future. */ if (update_timestamp) { - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - __wt_timestamp_set( - &prev_commit_timestamp, &txn_global->commit_timestamp)); - update_timestamp = __wt_timestamp_cmp( - &txn->commit_timestamp, &prev_commit_timestamp) > 0; + prev_commit_timestamp = txn_global->commit_timestamp; + update_timestamp = + txn->commit_timestamp > prev_commit_timestamp; } /* * If it looks like we need to move the global commit timestamp, * write lock and re-check. */ - if (update_timestamp) { -#if WT_TIMESTAMP_SIZE == 8 - while (__wt_timestamp_cmp( - &txn->commit_timestamp, &prev_commit_timestamp) > 0) { - if (__wt_atomic_cas64( - &txn_global->commit_timestamp.val, - prev_commit_timestamp.val, - txn->commit_timestamp.val)) { + if (update_timestamp) + while (txn->commit_timestamp > prev_commit_timestamp) { + if (__wt_atomic_cas64(&txn_global->commit_timestamp, + prev_commit_timestamp, txn->commit_timestamp)) { txn_global->has_commit_timestamp = true; break; } - __wt_timestamp_set( - &prev_commit_timestamp, &txn_global->commit_timestamp); - } -#else - __wt_writelock(session, &txn_global->rwlock); - if (__wt_timestamp_cmp(&txn->commit_timestamp, - &txn_global->commit_timestamp) > 0) { - __wt_timestamp_set(&txn_global->commit_timestamp, - &txn->commit_timestamp); - txn_global->has_commit_timestamp = true; + prev_commit_timestamp = txn_global->commit_timestamp; } - __wt_writeunlock(session, &txn_global->rwlock); -#endif - } -#endif /* * We're between transactions, if we need to block for eviction, it's @@ -963,7 +923,6 @@ err: /* int __wt_txn_prepare(WT_SESSION_IMPL *session, const char *cfg[]) { -#ifdef HAVE_TIMESTAMPS WT_TXN *txn; WT_TXN_OP *op; WT_UPDATE *upd; @@ -981,7 +940,7 @@ __wt_txn_prepare(WT_SESSION_IMPL *session, const char *cfg[]) /* Parse and validate the prepare timestamp. */ WT_RET(__wt_txn_parse_prepare_timestamp(session, cfg, &ts)); - __wt_timestamp_set(&txn->prepare_timestamp, &ts); + txn->prepare_timestamp = ts; /* * We are about to release the snapshot: copy values into any @@ -1026,15 +985,14 @@ __wt_txn_prepare(WT_SESSION_IMPL *session, const char *cfg[]) } /* Set prepare timestamp. */ - __wt_timestamp_set(&upd->timestamp, &ts); + upd->timestamp = ts; WT_PUBLISH(upd->prepare_state, WT_PREPARE_INPROGRESS); op->u.op_upd = NULL; WT_STAT_CONN_INCR(session, txn_prepared_updates_count); break; case WT_TXN_OP_REF_DELETE: - __wt_timestamp_set( - &op->u.ref->page_del->timestamp, &ts); + op->u.ref->page_del->timestamp = ts; WT_PUBLISH(op->u.ref->page_del->prepare_state, WT_PREPARE_INPROGRESS); break; @@ -1059,11 +1017,6 @@ __wt_txn_prepare(WT_SESSION_IMPL *session, const char *cfg[]) __txn_remove_from_global_table(session); return (0); -#else - WT_UNUSED(cfg); - WT_RET_MSG(session, ENOTSUP, "prepare_transaction requires a version " - "of WiredTiger built with timestamp support"); -#endif } /* @@ -1208,6 +1161,9 @@ __wt_txn_stats_update(WT_SESSION_IMPL *session) WT_CONNECTION_IMPL *conn; WT_CONNECTION_STATS **stats; WT_TXN_GLOBAL *txn_global; + wt_timestamp_t checkpoint_timestamp; + wt_timestamp_t commit_timestamp; + wt_timestamp_t pinned_timestamp; uint64_t checkpoint_pinned, snapshot_pinned; conn = S2C(session); @@ -1219,26 +1175,18 @@ __wt_txn_stats_update(WT_SESSION_IMPL *session) WT_STAT_SET(session, stats, txn_pinned_range, txn_global->current - txn_global->oldest_id); -#if WT_TIMESTAMP_SIZE == 8 - { - WT_DECL_TIMESTAMP(checkpoint_timestamp) - WT_DECL_TIMESTAMP(commit_timestamp) - WT_DECL_TIMESTAMP(pinned_timestamp) - checkpoint_timestamp = txn_global->checkpoint_timestamp; commit_timestamp = txn_global->commit_timestamp; pinned_timestamp = txn_global->pinned_timestamp; - if (checkpoint_timestamp.val != 0 && - checkpoint_timestamp.val < pinned_timestamp.val) + if (checkpoint_timestamp != 0 && + checkpoint_timestamp < pinned_timestamp) pinned_timestamp = checkpoint_timestamp; WT_STAT_SET(session, stats, txn_pinned_timestamp, - commit_timestamp.val - pinned_timestamp.val); + commit_timestamp - pinned_timestamp); WT_STAT_SET(session, stats, txn_pinned_timestamp_checkpoint, - commit_timestamp.val - checkpoint_timestamp.val); + commit_timestamp - checkpoint_timestamp); WT_STAT_SET(session, stats, txn_pinned_timestamp_oldest, - commit_timestamp.val - txn_global->oldest_timestamp.val); - } -#endif + commit_timestamp - txn_global->oldest_timestamp); WT_STAT_SET(session, stats, txn_pinned_snapshot_range, snapshot_pinned == WT_TXN_NONE ? @@ -1398,7 +1346,6 @@ __wt_txn_activity_drain(WT_SESSION_IMPL *session) void __wt_txn_global_shutdown(WT_SESSION_IMPL *session) { -#ifdef HAVE_TIMESTAMPS /* * All application transactions have completed, ignore the pinned * timestamp so that updates can be evicted from the cache during @@ -1409,9 +1356,6 @@ __wt_txn_global_shutdown(WT_SESSION_IMPL *session) * set. */ S2C(session)->txn_global.has_pinned_timestamp = false; -#else - WT_UNUSED(session); -#endif } /* @@ -1421,9 +1365,7 @@ __wt_txn_global_shutdown(WT_SESSION_IMPL *session) int __wt_verbose_dump_txn_one(WT_SESSION_IMPL *session, WT_TXN *txn) { -#ifdef HAVE_TIMESTAMPS - char hex_timestamp[3][2 * WT_TIMESTAMP_SIZE + 1]; -#endif + char hex_timestamp[3][WT_TS_HEX_SIZE]; const char *iso_tag; WT_NOT_READ(iso_tag, "INVALID"); @@ -1438,13 +1380,10 @@ __wt_verbose_dump_txn_one(WT_SESSION_IMPL *session, WT_TXN *txn) 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_timestamp_to_hex_string(hex_timestamp[0], txn->commit_timestamp); + __wt_timestamp_to_hex_string( + hex_timestamp[1], txn->first_commit_timestamp); + __wt_timestamp_to_hex_string(hex_timestamp[2], txn->read_timestamp); WT_RET(__wt_msg(session, "mod count: %u" ", snap min: %" PRIu64 @@ -1462,19 +1401,6 @@ __wt_verbose_dump_txn_one(WT_SESSION_IMPL *session, WT_TXN *txn) hex_timestamp[2], txn->flags, iso_tag)); -#else - WT_RET(__wt_msg(session, - "mod count: %u" - ", snap min: %" PRIu64 - ", snap max: %" PRIu64 - ", flags: 0x%08" PRIx32 - ", isolation: %s", - txn->mod_count, - txn->snap_min, - txn->snap_max, - txn->flags, - iso_tag)); -#endif return (0); } @@ -1491,9 +1417,7 @@ __wt_verbose_dump_txn(WT_SESSION_IMPL *session) WT_TXN_STATE *s; uint64_t id; uint32_t i, session_cnt; -#ifdef HAVE_TIMESTAMPS - char hex_timestamp[3][2 * WT_TIMESTAMP_SIZE + 1]; -#endif + char hex_timestamp[3][WT_TS_HEX_SIZE]; conn = S2C(session); txn_global = &conn->txn_global; @@ -1508,18 +1432,17 @@ __wt_verbose_dump_txn(WT_SESSION_IMPL *session) "metadata_pinned ID: %" PRIu64, txn_global->metadata_pinned)); WT_RET(__wt_msg(session, "oldest ID: %" PRIu64, txn_global->oldest_id)); -#ifdef HAVE_TIMESTAMPS - WT_RET(__wt_timestamp_to_hex_string( - session, hex_timestamp[0], &txn_global->commit_timestamp)); + __wt_timestamp_to_hex_string( + 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_timestamp_to_hex_string( + 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_timestamp_to_hex_string( + 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_timestamp_to_hex_string( + 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")); @@ -1533,7 +1456,6 @@ __wt_verbose_dump_txn(WT_SESSION_IMPL *session) 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")); diff --git a/src/third_party/wiredtiger/src/txn/txn_ckpt.c b/src/third_party/wiredtiger/src/txn/txn_ckpt.c index bddf8d926f4..3e377043fa7 100644 --- a/src/third_party/wiredtiger/src/txn/txn_ckpt.c +++ b/src/third_party/wiredtiger/src/txn/txn_ckpt.c @@ -634,7 +634,6 @@ __checkpoint_prepare( txn_state->id = txn_state->pinned_id = txn_state->metadata_pinned = WT_TXN_NONE; -#ifdef HAVE_TIMESTAMPS /* * Set the checkpoint transaction's timestamp, if requested. * @@ -654,29 +653,22 @@ __checkpoint_prepare( * timestamp until its checkpoint is complete. */ if (txn_global->has_stable_timestamp) { - __wt_timestamp_set(&txn->read_timestamp, - &txn_global->stable_timestamp); - __wt_timestamp_set(&txn_global->checkpoint_timestamp, - &txn->read_timestamp); + txn->read_timestamp = txn_global->stable_timestamp; + txn_global->checkpoint_timestamp = txn->read_timestamp; F_SET(txn, WT_TXN_HAS_TS_READ); if (!F_ISSET(conn, WT_CONN_RECOVERING)) - __wt_timestamp_set( - &txn_global->meta_ckpt_timestamp, - &txn->read_timestamp); + txn_global->meta_ckpt_timestamp = + txn->read_timestamp; } else if (!F_ISSET(conn, WT_CONN_RECOVERING)) - __wt_timestamp_set(&txn_global->meta_ckpt_timestamp, - &txn_global->recovery_timestamp); + txn_global->meta_ckpt_timestamp = + txn_global->recovery_timestamp; } else if (!F_ISSET(conn, WT_CONN_RECOVERING)) - __wt_timestamp_set_zero(&txn_global->meta_ckpt_timestamp); -#else - WT_UNUSED(use_timestamp); -#endif + txn_global->meta_ckpt_timestamp = 0; __wt_writeunlock(session, &txn_global->rwlock); -#ifdef HAVE_TIMESTAMPS if (F_ISSET(txn, WT_TXN_HAS_TS_READ)) { - __wt_verbose_timestamp(session, &txn->read_timestamp, + __wt_verbose_timestamp(session, txn->read_timestamp, "Checkpoint requested at stable timestamp"); /* @@ -687,7 +679,6 @@ __checkpoint_prepare( */ __wt_txn_get_snapshot(session); } -#endif /* * Get a list of handles we want to flush; for named checkpoints this @@ -768,22 +759,17 @@ __txn_checkpoint_can_skip(WT_SESSION_IMPL *session, return (0); } -#ifdef HAVE_TIMESTAMPS /* * If the checkpoint is using timestamps, and the stable timestamp * hasn't been updated since the last checkpoint there is nothing * more that could be written. */ if (use_timestamp && txn_global->has_stable_timestamp && - !__wt_timestamp_iszero(&txn_global->last_ckpt_timestamp) && - __wt_timestamp_cmp(&txn_global->last_ckpt_timestamp, - &txn_global->stable_timestamp) == 0) { + txn_global->last_ckpt_timestamp != 0 && + txn_global->last_ckpt_timestamp == txn_global->stable_timestamp) { *can_skipp = true; return (0); } -#else - WT_UNUSED(txn_global); -#endif return (0); } @@ -798,10 +784,10 @@ __txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) WT_CACHE *cache; WT_CONNECTION_IMPL *conn; WT_DECL_RET; - WT_DECL_TIMESTAMP(ckpt_tmp_ts) WT_TXN *txn; WT_TXN_GLOBAL *txn_global; WT_TXN_ISOLATION saved_isolation; + wt_timestamp_t ckpt_tmp_ts; uint64_t fsync_duration_usecs, generation, time_start, time_stop; u_int i; bool can_skip, failed, full, idle, logging, tracking, use_timestamp; @@ -928,7 +914,6 @@ __txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) */ session->dhandle = NULL; -#ifdef HAVE_TIMESTAMPS /* * Record the timestamp from the transaction if we were successful. * Store it in a temp variable now because it will be invalidated during @@ -936,12 +921,11 @@ __txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) * is successful. We have to set the system information before we * release the snapshot. */ - __wt_timestamp_set_zero(&ckpt_tmp_ts); + ckpt_tmp_ts = 0; if (full) { WT_ERR(__wt_meta_sysinfo_set(session)); - __wt_timestamp_set(&ckpt_tmp_ts, &txn->read_timestamp); + ckpt_tmp_ts = txn->read_timestamp; } -#endif /* Release the snapshot so we aren't pinning updates in cache. */ __wt_txn_release_snapshot(session); @@ -1016,7 +1000,7 @@ __txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) if (full) { __checkpoint_stats(session); -#ifdef HAVE_TIMESTAMPS + /* * If timestamps were used to define the content of the * checkpoint update the saved last checkpoint timestamp, @@ -1025,10 +1009,7 @@ __txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) * the saved last checkpoint timestamp regardless. */ if (use_timestamp) - __wt_timestamp_set( - &conn->txn_global.last_ckpt_timestamp, - &ckpt_tmp_ts); -#endif + conn->txn_global.last_ckpt_timestamp = ckpt_tmp_ts; } err: /* @@ -1884,7 +1865,7 @@ __wt_checkpoint_close(WT_SESSION_IMPL *session, bool final) WT_RET(__wt_txn_update_oldest( session, WT_TXN_OLDEST_STRICT | WT_TXN_OLDEST_WAIT)); return (__wt_txn_visible_all(session, btree->rec_max_txn, - WT_TIMESTAMP_NULL(&btree->rec_max_timestamp)) ? + btree->rec_max_timestamp) ? __wt_cache_op(session, WT_SYNC_DISCARD) : EBUSY); } diff --git a/src/third_party/wiredtiger/src/txn/txn_ext.c b/src/third_party/wiredtiger/src/txn/txn_ext.c index e0401c83be5..8617d3f0bec 100644 --- a/src/third_party/wiredtiger/src/txn/txn_ext.c +++ b/src/third_party/wiredtiger/src/txn/txn_ext.c @@ -102,5 +102,5 @@ __wt_ext_transaction_visible( (void)wt_api; /* Unused parameters */ return (__wt_txn_visible( - (WT_SESSION_IMPL *)wt_session, transaction_id, NULL)); + (WT_SESSION_IMPL *)wt_session, transaction_id, WT_TS_NONE)); } diff --git a/src/third_party/wiredtiger/src/txn/txn_nsnap.c b/src/third_party/wiredtiger/src/txn/txn_nsnap.c index ed1d5407de4..8ab76e2f745 100644 --- a/src/third_party/wiredtiger/src/txn/txn_nsnap.c +++ b/src/third_party/wiredtiger/src/txn/txn_nsnap.c @@ -43,13 +43,13 @@ __nsnap_drop_one(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *name) /* Bump the global ID if we are removing the first entry */ if (found == TAILQ_FIRST(&txn_global->nsnaph)) { WT_ASSERT(session, !__wt_txn_visible_all( - session, txn_global->nsnap_oldest_id, NULL)); + session, txn_global->nsnap_oldest_id, WT_TS_NONE)); txn_global->nsnap_oldest_id = (TAILQ_NEXT(found, q) != NULL) ? TAILQ_NEXT(found, q)->pinned_id : WT_TXN_NONE; WT_DIAGNOSTIC_YIELD; WT_ASSERT(session, txn_global->nsnap_oldest_id == WT_TXN_NONE || !__wt_txn_visible_all( - session, txn_global->nsnap_oldest_id, NULL)); + session, txn_global->nsnap_oldest_id, WT_TS_NONE)); } TAILQ_REMOVE(&txn_global->nsnaph, found, q); __nsnap_destroy(session, found); @@ -123,14 +123,14 @@ __nsnap_drop_to(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *name, bool inclusive) /* Now that the queue of named snapshots is updated, update the ID */ WT_ASSERT(session, !__wt_txn_visible_all( - session, txn_global->nsnap_oldest_id, NULL) && + session, txn_global->nsnap_oldest_id, WT_TS_NONE) && (new_nsnap_oldest == WT_TXN_NONE || WT_TXNID_LE(txn_global->nsnap_oldest_id, new_nsnap_oldest))); txn_global->nsnap_oldest_id = new_nsnap_oldest; WT_DIAGNOSTIC_YIELD; WT_ASSERT(session, new_nsnap_oldest == WT_TXN_NONE || - !__wt_txn_visible_all(session, new_nsnap_oldest, NULL)); + !__wt_txn_visible_all(session, new_nsnap_oldest, WT_TS_NONE)); return (0); } @@ -210,7 +210,8 @@ __wt_txn_named_snapshot_begin(WT_SESSION_IMPL *session, const char *cfg[]) if (TAILQ_EMPTY(&txn_global->nsnaph)) { WT_ASSERT(session, txn_global->nsnap_oldest_id == WT_TXN_NONE && - !__wt_txn_visible_all(session, nsnap_new->pinned_id, NULL)); + !__wt_txn_visible_all( + session, nsnap_new->pinned_id, WT_TS_NONE)); __wt_readlock(session, &txn_global->rwlock); txn_global->nsnap_oldest_id = nsnap_new->pinned_id; __wt_readunlock(session, &txn_global->rwlock); @@ -226,7 +227,7 @@ err: if (started_txn) { WT_TRET(__wt_txn_rollback(session, NULL)); WT_DIAGNOSTIC_YIELD; WT_ASSERT(session, - !__wt_txn_visible_all(session, pinned_id, NULL)); + !__wt_txn_visible_all(session, pinned_id, WT_TS_NONE)); } if (nsnap_new != NULL) @@ -310,7 +311,7 @@ __wt_txn_named_snapshot_get(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *nameval) __wt_readunlock(session, &txn_global->rwlock); WT_ASSERT(session, !__wt_txn_visible_all( - session, txn_state->pinned_id, NULL) && + session, txn_state->pinned_id, WT_TS_NONE) && txn_global->nsnap_oldest_id != WT_TXN_NONE && WT_TXNID_LE(txn_global->nsnap_oldest_id, txn_state->pinned_id)); diff --git a/src/third_party/wiredtiger/src/txn/txn_recover.c b/src/third_party/wiredtiger/src/txn/txn_recover.c index 0eb5483d7e2..72accb7e38f 100644 --- a/src/third_party/wiredtiger/src/txn/txn_recover.c +++ b/src/third_party/wiredtiger/src/txn/txn_recover.c @@ -355,13 +355,12 @@ __txn_log_recover(WT_SESSION_IMPL *session, static int __recovery_set_checkpoint_timestamp(WT_RECOVERY *r) { -#ifdef HAVE_TIMESTAMPS WT_CONFIG_ITEM cval; WT_CONNECTION_IMPL *conn; WT_DECL_RET; - WT_DECL_TIMESTAMP(ckpt_timestamp) WT_SESSION_IMPL *session; - char *sys_config; + wt_timestamp_t ckpt_timestamp; + char hex_timestamp[WT_TS_HEX_SIZE], *sys_config; sys_config = NULL; @@ -372,7 +371,7 @@ __recovery_set_checkpoint_timestamp(WT_RECOVERY *r) * save the stable timestamp of the last checkpoint for later query. * This gets saved in the connection. */ - __wt_timestamp_set_zero(&ckpt_timestamp); + ckpt_timestamp = 0; /* Search in the metadata for the system information. */ WT_ERR_NOTFOUND_OK( @@ -395,26 +394,19 @@ __recovery_set_checkpoint_timestamp(WT_RECOVERY *r) * timestamp so that the checkpoint after recovery writes the correct * value into the metadata. */ - __wt_timestamp_set( - &conn->txn_global.meta_ckpt_timestamp, &ckpt_timestamp); - __wt_timestamp_set( - &conn->txn_global.recovery_timestamp, &ckpt_timestamp); + conn->txn_global.meta_ckpt_timestamp = + conn->txn_global.recovery_timestamp = ckpt_timestamp; if (WT_VERBOSE_ISSET(session, WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS)) { - char hex_timestamp[2 * WT_TIMESTAMP_SIZE + 1]; - WT_TRET(__wt_timestamp_to_hex_string(session, - hex_timestamp, &conn->txn_global.recovery_timestamp)); + __wt_timestamp_to_hex_string( + hex_timestamp, conn->txn_global.recovery_timestamp); __wt_verbose(session, WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS, "Set global recovery timestamp: %s", hex_timestamp); } err: __wt_free(session, sys_config); return (ret); -#else - WT_UNUSED(r); - return (0); -#endif } /* @@ -554,10 +546,8 @@ __wt_txn_recover(WT_SESSION_IMPL *session) r.session = session; WT_MAX_LSN(&r.max_ckpt_lsn); WT_MAX_LSN(&r.max_rec_lsn); -#ifdef HAVE_TIMESTAMPS - __wt_timestamp_set_zero(&conn->txn_global.recovery_timestamp); - __wt_timestamp_set_zero(&conn->txn_global.meta_ckpt_timestamp); -#endif + conn->txn_global.recovery_timestamp = + conn->txn_global.meta_ckpt_timestamp = 0; F_SET(conn, WT_CONN_RECOVERING); WT_ERR(__wt_metadata_search(session, WT_METAFILE_URI, &config)); diff --git a/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c b/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c index aa4512b80b1..7b8e2ca06ae 100644 --- a/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c +++ b/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c @@ -8,7 +8,6 @@ #include "wt_internal.h" -#ifdef HAVE_TIMESTAMPS /* * __txn_rollback_to_stable_lookaside_fixup -- * Remove any updates that need to be rolled back from the lookaside file. @@ -19,10 +18,9 @@ __txn_rollback_to_stable_lookaside_fixup(WT_SESSION_IMPL *session) WT_CONNECTION_IMPL *conn; WT_CURSOR *cursor; WT_DECL_RET; - WT_DECL_TIMESTAMP(rollback_timestamp) - WT_DECL_TIMESTAMP(upd_timestamp) - WT_ITEM las_key, las_timestamp, las_value; + WT_ITEM las_key, las_value; WT_TXN_GLOBAL *txn_global; + wt_timestamp_t las_timestamp, rollback_timestamp; uint64_t las_counter, las_pageid, las_total, las_txnid; uint32_t las_id, session_flags; uint8_t prepare_state, upd_type; @@ -31,7 +29,6 @@ __txn_rollback_to_stable_lookaside_fixup(WT_SESSION_IMPL *session) cursor = NULL; las_total = 0; session_flags = 0; /* [-Werror=maybe-uninitialized] */ - WT_CLEAR(las_timestamp); /* * Copy the stable timestamp, otherwise we'd need to lock it each time @@ -40,9 +37,7 @@ __txn_rollback_to_stable_lookaside_fixup(WT_SESSION_IMPL *session) * violate protocol. */ txn_global = &conn->txn_global; - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - __wt_timestamp_set( - &rollback_timestamp, &txn_global->stable_timestamp)); + WT_ORDERED_READ(rollback_timestamp, txn_global->stable_timestamp); __wt_las_cursor(session, &cursor, &session_flags); @@ -66,16 +61,13 @@ __txn_rollback_to_stable_lookaside_fixup(WT_SESSION_IMPL *session) WT_ERR(cursor->get_value(cursor, &las_txnid, &las_timestamp, &prepare_state, &upd_type, &las_value)); - WT_ASSERT(session, las_timestamp.size == WT_TIMESTAMP_SIZE); - memcpy(&upd_timestamp, las_timestamp.data, las_timestamp.size); /* * Entries with no timestamp will have a timestamp of zero, * which will fail the following check and cause them to never * be removed. */ - if (__wt_timestamp_cmp( - &rollback_timestamp, &upd_timestamp) < 0) { + if (rollback_timestamp < las_timestamp) { WT_ERR(cursor->remove(cursor)); WT_STAT_CONN_INCR(session, txn_rollback_las_removed); --las_total; @@ -101,7 +93,7 @@ err: if (ret == 0) { */ static void __txn_abort_newer_update(WT_SESSION_IMPL *session, - WT_UPDATE *first_upd, wt_timestamp_t *rollback_timestamp) + WT_UPDATE *first_upd, wt_timestamp_t rollback_timestamp) { WT_UPDATE *upd; @@ -112,12 +104,10 @@ __txn_abort_newer_update(WT_SESSION_IMPL *session, * strict timestamp checking, assert that all more recent * updates were also rolled back. */ - if (upd->txnid == WT_TXN_ABORTED || - __wt_timestamp_iszero(&upd->timestamp)) { + if (upd->txnid == WT_TXN_ABORTED || upd->timestamp == 0) { if (upd == first_upd) first_upd = upd->next; - } else if (__wt_timestamp_cmp( - rollback_timestamp, &upd->timestamp) < 0) { + } else if (rollback_timestamp < upd->timestamp) { /* * If any updates are aborted, all newer updates * better be aborted as well. @@ -135,7 +125,7 @@ __txn_abort_newer_update(WT_SESSION_IMPL *session, upd->txnid = WT_TXN_ABORTED; WT_STAT_CONN_INCR(session, txn_rollback_upd_aborted); - __wt_timestamp_set_zero(&upd->timestamp); + upd->timestamp = 0; } } } @@ -146,7 +136,7 @@ __txn_abort_newer_update(WT_SESSION_IMPL *session, */ static void __txn_abort_newer_insert(WT_SESSION_IMPL *session, - WT_INSERT_HEAD *head, wt_timestamp_t *rollback_timestamp) + WT_INSERT_HEAD *head, wt_timestamp_t rollback_timestamp) { WT_INSERT *ins; @@ -161,7 +151,7 @@ __txn_abort_newer_insert(WT_SESSION_IMPL *session, */ static void __txn_abort_newer_col_var( - WT_SESSION_IMPL *session, WT_PAGE *page, wt_timestamp_t *rollback_timestamp) + WT_SESSION_IMPL *session, WT_PAGE *page, wt_timestamp_t rollback_timestamp) { WT_COL *cip; WT_INSERT_HEAD *ins; @@ -185,7 +175,7 @@ __txn_abort_newer_col_var( */ static void __txn_abort_newer_col_fix( - WT_SESSION_IMPL *session, WT_PAGE *page, wt_timestamp_t *rollback_timestamp) + WT_SESSION_IMPL *session, WT_PAGE *page, wt_timestamp_t rollback_timestamp) { WT_INSERT_HEAD *ins; @@ -205,7 +195,7 @@ __txn_abort_newer_col_fix( */ static void __txn_abort_newer_row_leaf( - WT_SESSION_IMPL *session, WT_PAGE *page, wt_timestamp_t *rollback_timestamp) + WT_SESSION_IMPL *session, WT_PAGE *page, wt_timestamp_t rollback_timestamp) { WT_INSERT_HEAD *insert; WT_ROW *rip; @@ -240,7 +230,7 @@ __txn_abort_newer_row_leaf( */ static int __txn_abort_newer_updates( - WT_SESSION_IMPL *session, WT_REF *ref, wt_timestamp_t *rollback_timestamp) + WT_SESSION_IMPL *session, WT_REF *ref, wt_timestamp_t rollback_timestamp) { WT_DECL_RET; WT_PAGE *page; @@ -257,8 +247,7 @@ __txn_abort_newer_updates( local_read = false; read_flags = WT_READ_WONT_NEED; if (ref->page_las != NULL && ref->page_las->skew_newest && - __wt_timestamp_cmp(rollback_timestamp, - &ref->page_las->unstable_timestamp) < 0) { + rollback_timestamp < ref->page_las->unstable_timestamp) { /* Make sure get back a page with history, not limbo page */ WT_ASSERT(session, !F_ISSET(&session->txn, WT_TXN_HAS_SNAPSHOT)); @@ -269,8 +258,8 @@ __txn_abort_newer_updates( } /* Review deleted page saved to the ref */ - if (ref->page_del != NULL && __wt_timestamp_cmp( - rollback_timestamp, &ref->page_del->timestamp) < 0) + if (ref->page_del != NULL && + rollback_timestamp < ref->page_del->timestamp) WT_ERR(__wt_delete_page_rollback(session, ref)); /* @@ -323,7 +312,7 @@ err: if (local_read) */ static int __txn_rollback_to_stable_btree_walk( - WT_SESSION_IMPL *session, wt_timestamp_t *rollback_timestamp) + WT_SESSION_IMPL *session, wt_timestamp_t rollback_timestamp) { WT_DECL_RET; WT_REF *child_ref, *ref; @@ -369,8 +358,8 @@ __txn_rollback_to_stable_btree(WT_SESSION_IMPL *session, const char *cfg[]) WT_BTREE *btree; WT_CONNECTION_IMPL *conn; WT_DECL_RET; - WT_DECL_TIMESTAMP(rollback_timestamp) WT_TXN_GLOBAL *txn_global; + wt_timestamp_t rollback_timestamp; WT_UNUSED(cfg); @@ -413,9 +402,7 @@ __txn_rollback_to_stable_btree(WT_SESSION_IMPL *session, const char *cfg[]) * updated while rolling back, accessing it without a lock would * violate protocol. */ - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - __wt_timestamp_set( - &rollback_timestamp, &txn_global->stable_timestamp)); + WT_ORDERED_READ(rollback_timestamp, txn_global->stable_timestamp); /* * Ensure the eviction server is out of the file - we don't @@ -424,8 +411,8 @@ __txn_rollback_to_stable_btree(WT_SESSION_IMPL *session, const char *cfg[]) * be in. */ WT_RET(__wt_evict_file_exclusive_on(session)); - WT_WITH_PAGE_INDEX(session, ret = __txn_rollback_to_stable_btree_walk( - session, &rollback_timestamp)); + WT_WITH_PAGE_INDEX(session, ret = + __txn_rollback_to_stable_btree_walk(session, rollback_timestamp)); __wt_evict_file_exclusive_off(session); return (ret); @@ -465,7 +452,6 @@ __txn_rollback_to_stable_check(WT_SESSION_IMPL *session) return (ret); } -#endif /* * __wt_txn_rollback_to_stable -- @@ -475,12 +461,6 @@ __txn_rollback_to_stable_check(WT_SESSION_IMPL *session) int __wt_txn_rollback_to_stable(WT_SESSION_IMPL *session, const char *cfg[]) { -#ifndef HAVE_TIMESTAMPS - WT_UNUSED(cfg); - - WT_RET_MSG(session, ENOTSUP, "rollback_to_stable " - "requires a version of WiredTiger built with timestamp support"); -#else WT_CONNECTION_IMPL *conn; WT_DECL_RET; @@ -529,5 +509,4 @@ __wt_txn_rollback_to_stable(WT_SESSION_IMPL *session, const char *cfg[]) err: F_CLR(conn, WT_CONN_EVICTION_NO_LOOKASIDE); __wt_free(session, conn->stable_rollback_bitstring); return (ret); -#endif } diff --git a/src/third_party/wiredtiger/src/txn/txn_timestamp.c b/src/third_party/wiredtiger/src/txn/txn_timestamp.c index 3cb8bf79ef7..b58152f8599 100644 --- a/src/third_party/wiredtiger/src/txn/txn_timestamp.c +++ b/src/third_party/wiredtiger/src/txn/txn_timestamp.c @@ -8,7 +8,6 @@ #include "wt_internal.h" -#ifdef HAVE_TIMESTAMPS /* AUTOMATIC FLAG VALUE GENERATION START */ #define WT_TXN_TS_ALREADY_LOCKED 0x1u #define WT_TXN_TS_INCLUDE_CKPT 0x2u @@ -19,26 +18,19 @@ * __wt_timestamp_to_hex_string -- * Convert a timestamp to hex string representation. */ -int -__wt_timestamp_to_hex_string( - WT_SESSION_IMPL *session, char *hex_timestamp, const wt_timestamp_t *ts_src) +void +__wt_timestamp_to_hex_string(char *hex_timestamp, wt_timestamp_t ts) { - wt_timestamp_t ts; - - __wt_timestamp_set(&ts, ts_src); + char *p, v; - if (__wt_timestamp_iszero(&ts)) { + if (ts == 0) { hex_timestamp[0] = '0'; hex_timestamp[1] = '\0'; - return (0); + return; } -#if WT_TIMESTAMP_SIZE == 8 - { - char *p, v; - - for (p = hex_timestamp; ts.val != 0; ts.val >>= 4) - *p++ = (char)__wt_hex((u_char)(ts.val & 0x0f)); + for (p = hex_timestamp; ts != 0; ts >>= 4) + *p++ = (char)__wt_hex((u_char)(ts & 0x0f)); *p = '\0'; /* Reverse the string. */ @@ -47,26 +39,6 @@ __wt_timestamp_to_hex_string( *p-- = *hex_timestamp; *hex_timestamp++ = v; } - WT_UNUSED(session); - } -#else - { - WT_ITEM hexts; - size_t len; - uint8_t *tsp; - - /* Avoid memory allocation: set up an item guaranteed large enough. */ - hexts.data = hexts.mem = hex_timestamp; - hexts.memsize = 2 * WT_TIMESTAMP_SIZE + 1; - /* Trim leading zeros. */ - for (tsp = ts.ts, len = WT_TIMESTAMP_SIZE; - len > 0 && *tsp == 0; - ++tsp, --len) - ; - WT_RET(__wt_raw_to_hex(session, tsp, len, &hexts)); - } -#endif - return (0); } /* @@ -74,15 +46,15 @@ __wt_timestamp_to_hex_string( * Output a verbose message along with the specified timestamp. */ void -__wt_verbose_timestamp(WT_SESSION_IMPL *session, - const wt_timestamp_t *ts, const char *msg) +__wt_verbose_timestamp( + WT_SESSION_IMPL *session, wt_timestamp_t ts, const char *msg) { - char timestamp_buf[2 * WT_TIMESTAMP_SIZE + 1]; + char timestamp_buf[WT_TS_HEX_SIZE]; - if (!WT_VERBOSE_ISSET(session, WT_VERB_TIMESTAMP) || - (__wt_timestamp_to_hex_string(session, timestamp_buf, ts) != 0)) - return; + if (!WT_VERBOSE_ISSET(session, WT_VERB_TIMESTAMP)) + return; + __wt_timestamp_to_hex_string(timestamp_buf, ts); __wt_verbose(session, WT_VERB_TIMESTAMP, "Timestamp %s : %s", timestamp_buf, msg); } @@ -95,19 +67,6 @@ int __wt_txn_parse_timestamp_raw(WT_SESSION_IMPL *session, const char *name, wt_timestamp_t *timestamp, WT_CONFIG_ITEM *cval) { - __wt_timestamp_set_zero(timestamp); - - if (cval->len == 0) - return (0); - - /* Protect against unexpectedly long hex strings. */ - if (cval->len > 2 * WT_TIMESTAMP_SIZE) - WT_RET_MSG(session, EINVAL, - "%s timestamp too long '%.*s'", - name, (int)cval->len, cval->str); - -#if WT_TIMESTAMP_SIZE == 8 - { static const int8_t hextable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -128,7 +87,18 @@ __wt_txn_parse_timestamp_raw(WT_SESSION_IMPL *session, const char *name, int hex_val; const char *hex_itr; - for (ts.val = 0, hex_itr = cval->str, len = cval->len; len > 0; --len) { + *timestamp = 0; + + if (cval->len == 0) + return (0); + + /* Protect against unexpectedly long hex strings. */ + if (cval->len > 2 * sizeof(wt_timestamp_t)) + WT_RET_MSG(session, EINVAL, + "%s timestamp too long '%.*s'", + name, (int)cval->len, cval->str); + + for (ts = 0, hex_itr = cval->str, len = cval->len; len > 0; --len) { if ((size_t)*hex_itr < WT_ELEMENTS(hextable)) hex_val = hextable[(size_t)*hex_itr++]; else @@ -137,47 +107,10 @@ __wt_txn_parse_timestamp_raw(WT_SESSION_IMPL *session, const char *name, WT_RET_MSG(session, EINVAL, "Failed to parse %s timestamp '%.*s'", name, (int)cval->len, cval->str); - ts.val = (ts.val << 4) | (uint64_t)hex_val; + ts = (ts << 4) | (uint64_t)hex_val; } - __wt_timestamp_set(timestamp, &ts); - } -#else - { - WT_DECL_RET; - WT_ITEM ts; - wt_timestamp_t tsbuf; - size_t hexlen; - const char *hexts; - char padbuf[2 * WT_TIMESTAMP_SIZE + 1]; - - /* - * The decoding function assumes it is decoding data produced by dump - * and so requires an even number of hex digits. - */ - if ((cval->len & 1) == 0) { - hexts = cval->str; - hexlen = cval->len; - } else { - padbuf[0] = '0'; - memcpy(padbuf + 1, cval->str, cval->len); - hexts = padbuf; - hexlen = cval->len + 1; - } - - /* Avoid memory allocation to decode timestamps. */ - ts.data = ts.mem = tsbuf.ts; - ts.memsize = sizeof(tsbuf.ts); - - if ((ret = __wt_nhex_to_raw(session, hexts, hexlen, &ts)) != 0) - WT_RET_MSG(session, ret, "Failed to parse %s timestamp '%.*s'", - name, (int)cval->len, cval->str); - WT_ASSERT(session, ts.size <= WT_TIMESTAMP_SIZE); + *timestamp = ts; - /* Copy the raw value to the end of the timestamp. */ - memcpy(timestamp->ts + WT_TIMESTAMP_SIZE - ts.size, - ts.data, ts.size); - } -#endif return (0); } @@ -190,7 +123,7 @@ __wt_txn_parse_timestamp(WT_SESSION_IMPL *session, const char *name, wt_timestamp_t *timestamp, WT_CONFIG_ITEM *cval) { WT_RET(__wt_txn_parse_timestamp_raw(session, name, timestamp, cval)); - if (cval->len != 0 && __wt_timestamp_iszero(timestamp)) + if (cval->len != 0 && *timestamp == 0) WT_RET_MSG(session, EINVAL, "Failed to parse %s timestamp '%.*s': zero not permitted", name, (int)cval->len, cval->str); @@ -207,9 +140,9 @@ __txn_get_pinned_timestamp( WT_SESSION_IMPL *session, wt_timestamp_t *tsp, uint32_t flags) { WT_CONNECTION_IMPL *conn; - WT_DECL_TIMESTAMP(tmp_ts) WT_TXN *txn; WT_TXN_GLOBAL *txn_global; + wt_timestamp_t tmp_ts; bool include_oldest, txn_has_write_lock; conn = S2C(session); @@ -222,18 +155,14 @@ __txn_get_pinned_timestamp( if (!txn_has_write_lock) __wt_readlock(session, &txn_global->rwlock); - if (include_oldest) - __wt_timestamp_set(&tmp_ts, &txn_global->oldest_timestamp); - else - __wt_timestamp_set_zero(&tmp_ts); + + tmp_ts = include_oldest ? txn_global->oldest_timestamp : 0; /* Check for a running checkpoint */ if (LF_ISSET(WT_TXN_TS_INCLUDE_CKPT) && - !__wt_timestamp_iszero(&txn_global->checkpoint_timestamp) && - (__wt_timestamp_iszero(&tmp_ts) || - __wt_timestamp_cmp(&txn_global->checkpoint_timestamp, &tmp_ts) < - 0)) - __wt_timestamp_set(&tmp_ts, &txn_global->checkpoint_timestamp); + txn_global->checkpoint_timestamp != 0 && + (tmp_ts == 0 || txn_global->checkpoint_timestamp < tmp_ts)) + tmp_ts = txn_global->checkpoint_timestamp; if (!txn_has_write_lock) __wt_readunlock(session, &txn_global->rwlock); @@ -249,9 +178,8 @@ __txn_get_pinned_timestamp( * A zero timestamp is possible here only when the oldest * timestamp is not accounted for. */ - if (__wt_timestamp_iszero(&tmp_ts) || - __wt_timestamp_cmp(&txn->read_timestamp, &tmp_ts) < 0) - __wt_timestamp_set(&tmp_ts, &txn->read_timestamp); + if (tmp_ts == 0 || txn->read_timestamp < tmp_ts) + tmp_ts = txn->read_timestamp; /* * We break on the first active txn on the list. */ @@ -259,9 +187,9 @@ __txn_get_pinned_timestamp( } __wt_readunlock(session, &txn_global->read_timestamp_rwlock); - if (!include_oldest && __wt_timestamp_iszero(&tmp_ts)) + if (!include_oldest && tmp_ts == 0) return (WT_NOTFOUND); - __wt_timestamp_set(tsp, &tmp_ts); + *tsp = tmp_ts; return (0); } @@ -288,9 +216,8 @@ __txn_global_query_timestamp( if (WT_STRING_MATCH("all_committed", cval.str, cval.len)) { if (!txn_global->has_commit_timestamp) return (WT_NOTFOUND); - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - __wt_timestamp_set(&ts, &txn_global->commit_timestamp)); - WT_ASSERT(session, !__wt_timestamp_iszero(&ts)); + ts = txn_global->commit_timestamp; + WT_ASSERT(session, ts != 0); /* Skip the lock if there are no running transactions. */ if (TAILQ_EMPTY(&txn_global->commit_timestamph)) @@ -303,24 +230,22 @@ __txn_global_query_timestamp( if (txn->clear_commit_q) continue; - __wt_timestamp_set( - &tmpts, &txn->first_commit_timestamp); - WT_ASSERT(session, !__wt_timestamp_iszero(&tmpts)); - __wt_timestamp_subone(&tmpts); + tmpts = txn->first_commit_timestamp; + WT_ASSERT(session, tmpts != 0); + tmpts -= 1; - if (__wt_timestamp_cmp(&tmpts, &ts) < 0) - __wt_timestamp_set(&ts, &tmpts); + if (tmpts < ts) + ts = tmpts; break; } __wt_readunlock(session, &txn_global->commit_timestamp_rwlock); } else if (WT_STRING_MATCH("last_checkpoint", cval.str, cval.len)) /* Read-only value forever. No lock needed. */ - __wt_timestamp_set(&ts, &txn_global->last_ckpt_timestamp); + ts = txn_global->last_ckpt_timestamp; else if (WT_STRING_MATCH("oldest", cval.str, cval.len)) { if (!txn_global->has_oldest_timestamp) return (WT_NOTFOUND); - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - __wt_timestamp_set(&ts, &txn_global->oldest_timestamp)); + ts = txn_global->oldest_timestamp; } else if (WT_STRING_MATCH("oldest_reader", cval.str, cval.len)) WT_RET(__txn_get_pinned_timestamp( session, &ts, WT_TXN_TS_INCLUDE_CKPT)); @@ -329,17 +254,16 @@ __txn_global_query_timestamp( WT_TXN_TS_INCLUDE_CKPT | WT_TXN_TS_INCLUDE_OLDEST)); else if (WT_STRING_MATCH("recovery", cval.str, cval.len)) /* Read-only value forever. No lock needed. */ - __wt_timestamp_set(&ts, &txn_global->recovery_timestamp); + ts = txn_global->recovery_timestamp; else if (WT_STRING_MATCH("stable", cval.str, cval.len)) { if (!txn_global->has_stable_timestamp) return (WT_NOTFOUND); - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - __wt_timestamp_set(&ts, &txn_global->stable_timestamp)); + ts = txn_global->stable_timestamp; } else WT_RET_MSG(session, EINVAL, "unknown timestamp query %.*s", (int)cval.len, cval.str); -done: __wt_timestamp_set(tsp, &ts); +done: *tsp = ts; return (0); } @@ -362,20 +286,19 @@ __txn_query_timestamp( WT_RET(__wt_config_gets(session, cfg, "get", &cval)); if (WT_STRING_MATCH("commit", cval.str, cval.len)) - __wt_timestamp_set(tsp, &txn->commit_timestamp); + *tsp = txn->commit_timestamp; else if (WT_STRING_MATCH("first_commit", cval.str, cval.len)) - __wt_timestamp_set(tsp, &txn->first_commit_timestamp); + *tsp = txn->first_commit_timestamp; else if (WT_STRING_MATCH("prepare", cval.str, cval.len)) - __wt_timestamp_set(tsp, &txn->prepare_timestamp); + *tsp = txn->prepare_timestamp; else if (WT_STRING_MATCH("read", cval.str, cval.len)) - __wt_timestamp_set(tsp, &txn->read_timestamp); + *tsp = txn->read_timestamp; else WT_RET_MSG(session, EINVAL, "unknown timestamp query %.*s", (int)cval.len, cval.str); return (0); } -#endif /* * __wt_txn_query_timestamp -- @@ -386,7 +309,6 @@ int __wt_txn_query_timestamp(WT_SESSION_IMPL *session, char *hex_timestamp, const char *cfg[], bool global_txn) { -#ifdef HAVE_TIMESTAMPS wt_timestamp_t ts; if (global_txn) @@ -394,18 +316,10 @@ __wt_txn_query_timestamp(WT_SESSION_IMPL *session, else WT_RET(__txn_query_timestamp(session, &ts, cfg)); - return (__wt_timestamp_to_hex_string(session, hex_timestamp, &ts)); -#else - WT_UNUSED(hex_timestamp); - WT_UNUSED(cfg); - WT_UNUSED(global_txn); - - WT_RET_MSG(session, ENOTSUP, - "requires a version of WiredTiger built with timestamp support"); -#endif + __wt_timestamp_to_hex_string(hex_timestamp, ts); + return (0); } -#ifdef HAVE_TIMESTAMPS /* * __wt_txn_update_pinned_timestamp -- * Update the pinned timestamp (the oldest timestamp that has to be @@ -430,12 +344,9 @@ __wt_txn_update_pinned_timestamp(WT_SESSION_IMPL *session, bool force) return (ret == WT_NOTFOUND ? 0 : ret); if (txn_global->has_pinned_timestamp && !force) { - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - __wt_timestamp_set( - &last_pinned_timestamp, &txn_global->pinned_timestamp)); + last_pinned_timestamp = txn_global->pinned_timestamp; - if (__wt_timestamp_cmp( - &pinned_timestamp, &last_pinned_timestamp) <= 0) + if (pinned_timestamp <= last_pinned_timestamp) return (0); } @@ -450,25 +361,23 @@ __wt_txn_update_pinned_timestamp(WT_SESSION_IMPL *session, bool force) return (ret == WT_NOTFOUND ? 0 : ret); } - if (!txn_global->has_pinned_timestamp || force || __wt_timestamp_cmp( - &txn_global->pinned_timestamp, &pinned_timestamp) < 0) { - __wt_timestamp_set( - &txn_global->pinned_timestamp, &pinned_timestamp); + if (!txn_global->has_pinned_timestamp || force || + txn_global->pinned_timestamp < pinned_timestamp) { + txn_global->pinned_timestamp = pinned_timestamp; txn_global->has_pinned_timestamp = true; - txn_global->oldest_is_pinned = __wt_timestamp_cmp( - &txn_global->pinned_timestamp, - &txn_global->oldest_timestamp) == 0; - txn_global->stable_is_pinned = __wt_timestamp_cmp( - &txn_global->pinned_timestamp, - &txn_global->stable_timestamp) == 0; + txn_global->oldest_is_pinned = + txn_global->pinned_timestamp == + txn_global->oldest_timestamp; + txn_global->stable_is_pinned = + txn_global->pinned_timestamp == + txn_global->stable_timestamp; __wt_verbose_timestamp(session, - &pinned_timestamp, "Updated pinned timestamp"); + pinned_timestamp, "Updated pinned timestamp"); } __wt_writeunlock(session, &txn_global->rwlock); return (0); } -#endif /* * __wt_txn_global_set_timestamp -- @@ -478,7 +387,14 @@ int __wt_txn_global_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) { WT_CONFIG_ITEM commit_cval, oldest_cval, stable_cval; - bool has_commit, has_oldest, has_stable; + WT_CONFIG_ITEM cval; + WT_TXN_GLOBAL *txn_global; + wt_timestamp_t commit_ts, oldest_ts, stable_ts; + wt_timestamp_t last_oldest_ts, last_stable_ts; + char hex_timestamp[2][WT_TS_HEX_SIZE]; + bool force, has_commit, has_oldest, has_stable; + + txn_global = &S2C(session)->txn_global; WT_STAT_CONN_INCR(session, txn_set_ts); WT_RET(__wt_config_gets_def(session, @@ -503,17 +419,6 @@ __wt_txn_global_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) if (!has_commit && !has_oldest && !has_stable) return (0); -#ifdef HAVE_TIMESTAMPS - { - WT_CONFIG_ITEM cval; - WT_TXN_GLOBAL *txn_global; - wt_timestamp_t commit_ts, oldest_ts, stable_ts; - wt_timestamp_t last_oldest_ts, last_stable_ts; - char hex_timestamp[2][2 * WT_TIMESTAMP_SIZE + 1]; - bool force; - - txn_global = &S2C(session)->txn_global; - /* * Parsing will initialize the timestamp to zero even if * it is not configured. @@ -534,8 +439,8 @@ __wt_txn_global_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) __wt_readlock(session, &txn_global->rwlock); - __wt_timestamp_set(&last_oldest_ts, &txn_global->oldest_timestamp); - __wt_timestamp_set(&last_stable_ts, &txn_global->stable_timestamp); + last_oldest_ts = txn_global->oldest_timestamp; + last_stable_ts = txn_global->stable_timestamp; /* * First do error checking on the timestamp values. The @@ -545,35 +450,31 @@ __wt_txn_global_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) * setting both then compare the passed in values. */ if (!has_commit && txn_global->has_commit_timestamp) - __wt_timestamp_set(&commit_ts, &txn_global->commit_timestamp); + commit_ts = txn_global->commit_timestamp; if (!has_oldest && txn_global->has_oldest_timestamp) - __wt_timestamp_set(&oldest_ts, &last_oldest_ts); + oldest_ts = last_oldest_ts; if (!has_stable && txn_global->has_stable_timestamp) - __wt_timestamp_set(&stable_ts, &last_stable_ts); + stable_ts = last_stable_ts; /* * If a commit timestamp was supplied, check that it is no older than * either the stable timestamp or the oldest timestamp. */ - if (has_commit && (has_oldest || txn_global->has_oldest_timestamp) && - __wt_timestamp_cmp(&oldest_ts, &commit_ts) > 0) { + if (has_commit && (has_oldest || + txn_global->has_oldest_timestamp) && oldest_ts > commit_ts) { __wt_readunlock(session, &txn_global->rwlock); - WT_RET(__wt_timestamp_to_hex_string( - session, hex_timestamp[0], &oldest_ts)); - WT_RET(__wt_timestamp_to_hex_string( - session, hex_timestamp[1], &commit_ts)); + __wt_timestamp_to_hex_string(hex_timestamp[0], oldest_ts); + __wt_timestamp_to_hex_string(hex_timestamp[1], commit_ts); WT_RET_MSG(session, EINVAL, "set_timestamp: oldest timestamp %s must not be later than " "commit timestamp %s", hex_timestamp[0], hex_timestamp[1]); } - if (has_commit && (has_stable || txn_global->has_stable_timestamp) && - __wt_timestamp_cmp(&stable_ts, &commit_ts) > 0) { + if (has_commit && (has_stable || + txn_global->has_stable_timestamp) && stable_ts > commit_ts) { __wt_readunlock(session, &txn_global->rwlock); - WT_RET(__wt_timestamp_to_hex_string( - session, hex_timestamp[0], &stable_ts)); - WT_RET(__wt_timestamp_to_hex_string( - session, hex_timestamp[1], &commit_ts)); + __wt_timestamp_to_hex_string(hex_timestamp[0], stable_ts); + __wt_timestamp_to_hex_string(hex_timestamp[1], commit_ts); WT_RET_MSG(session, EINVAL, "set_timestamp: stable timestamp %s must not be later than " "commit timestamp %s", hex_timestamp[0], hex_timestamp[1]); @@ -585,13 +486,11 @@ __wt_txn_global_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) */ if ((has_oldest || has_stable) && (has_oldest || txn_global->has_oldest_timestamp) && - (has_stable || txn_global->has_stable_timestamp) && - __wt_timestamp_cmp(&oldest_ts, &stable_ts) > 0) { + (has_stable || + txn_global->has_stable_timestamp) && oldest_ts > stable_ts) { __wt_readunlock(session, &txn_global->rwlock); - WT_RET(__wt_timestamp_to_hex_string( - session, hex_timestamp[0], &oldest_ts)); - WT_RET(__wt_timestamp_to_hex_string( - session, hex_timestamp[1], &stable_ts)); + __wt_timestamp_to_hex_string(hex_timestamp[0], oldest_ts); + __wt_timestamp_to_hex_string(hex_timestamp[1], stable_ts); WT_RET_MSG(session, EINVAL, "set_timestamp: oldest timestamp %s must not be later than " "stable timestamp %s", hex_timestamp[0], hex_timestamp[1]); @@ -600,12 +499,12 @@ __wt_txn_global_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) __wt_readunlock(session, &txn_global->rwlock); /* Check if we are actually updating anything. */ - if (has_oldest && txn_global->has_oldest_timestamp && - __wt_timestamp_cmp(&oldest_ts, &last_oldest_ts) <= 0) + if (has_oldest && + txn_global->has_oldest_timestamp && oldest_ts <= last_oldest_ts) has_oldest = false; - if (has_stable && txn_global->has_stable_timestamp && - __wt_timestamp_cmp(&stable_ts, &last_stable_ts) <= 0) + if (has_stable && + txn_global->has_stable_timestamp && stable_ts <= last_stable_ts) has_stable = false; if (!has_commit && !has_oldest && !has_stable) @@ -623,47 +522,40 @@ set: __wt_writelock(session, &txn_global->rwlock); * assigned timestamps). */ if (has_commit) { - __wt_timestamp_set(&txn_global->commit_timestamp, &commit_ts); + txn_global->commit_timestamp = commit_ts; txn_global->has_commit_timestamp = true; WT_STAT_CONN_INCR(session, txn_set_ts_commit_upd); - __wt_verbose_timestamp(session, &commit_ts, + __wt_verbose_timestamp(session, commit_ts, "Updated global commit timestamp"); } - if (has_oldest && (!txn_global->has_oldest_timestamp || - force || __wt_timestamp_cmp( - &oldest_ts, &txn_global->oldest_timestamp) > 0)) { - __wt_timestamp_set(&txn_global->oldest_timestamp, &oldest_ts); + if (has_oldest && (!txn_global->has_oldest_timestamp || force || + oldest_ts > txn_global->oldest_timestamp)) { + txn_global->oldest_timestamp = oldest_ts; WT_STAT_CONN_INCR(session, txn_set_ts_oldest_upd); txn_global->has_oldest_timestamp = true; txn_global->oldest_is_pinned = false; - __wt_verbose_timestamp(session, &oldest_ts, + __wt_verbose_timestamp(session, oldest_ts, "Updated global oldest timestamp"); } - if (has_stable && (!txn_global->has_stable_timestamp || - force || __wt_timestamp_cmp( - &stable_ts, &txn_global->stable_timestamp) > 0)) { - __wt_timestamp_set(&txn_global->stable_timestamp, &stable_ts); + if (has_stable && (!txn_global->has_stable_timestamp || force || + stable_ts > txn_global->stable_timestamp)) { + txn_global->stable_timestamp = stable_ts; WT_STAT_CONN_INCR(session, txn_set_ts_stable_upd); txn_global->has_stable_timestamp = true; txn_global->stable_is_pinned = false; - __wt_verbose_timestamp(session, &stable_ts, + __wt_verbose_timestamp(session, stable_ts, "Updated global stable timestamp"); } __wt_writeunlock(session, &txn_global->rwlock); if (has_oldest || has_stable) WT_RET(__wt_txn_update_pinned_timestamp(session, force)); - } + return (0); -#else - WT_RET_MSG(session, ENOTSUP, "set_timestamp requires a " - "version of WiredTiger built with timestamp support"); -#endif } -#ifdef HAVE_TIMESTAMPS /* * __wt_timestamp_validate -- * Validate a timestamp to be not older than the global oldest and global @@ -672,39 +564,37 @@ set: __wt_writelock(session, &txn_global->rwlock); */ int __wt_timestamp_validate(WT_SESSION_IMPL *session, const char *name, - wt_timestamp_t *ts, WT_CONFIG_ITEM *cval) + wt_timestamp_t ts, WT_CONFIG_ITEM *cval) { WT_TXN *txn = &session->txn; WT_TXN_GLOBAL *txn_global = &S2C(session)->txn_global; wt_timestamp_t oldest_ts, stable_ts; - char hex_timestamp[2 * WT_TIMESTAMP_SIZE + 1]; + char hex_timestamp[WT_TS_HEX_SIZE]; bool has_oldest_ts, has_stable_ts; /* * Added this redundant initialization to circumvent build failure. */ - __wt_timestamp_set_zero(&oldest_ts); - __wt_timestamp_set_zero(&stable_ts); + oldest_ts = stable_ts = 0; /* * Compare against the oldest and the stable timestamp. Return an error * if the given timestamp is older than oldest and/or stable timestamp. */ - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - if ((has_oldest_ts = txn_global->has_oldest_timestamp)) - __wt_timestamp_set(&oldest_ts, &txn_global->oldest_timestamp); - if ((has_stable_ts = txn_global->has_stable_timestamp)) - __wt_timestamp_set(&stable_ts, &txn_global->stable_timestamp)); - - if (has_oldest_ts && __wt_timestamp_cmp(ts, &oldest_ts) < 0) { - WT_RET(__wt_timestamp_to_hex_string(session, hex_timestamp, - &oldest_ts)); + has_oldest_ts = txn_global->has_oldest_timestamp; + if (has_oldest_ts) + oldest_ts = txn_global->oldest_timestamp; + has_stable_ts = txn_global->has_stable_timestamp; + if (has_stable_ts) + stable_ts = txn_global->stable_timestamp; + + if (has_oldest_ts && ts < oldest_ts) { + __wt_timestamp_to_hex_string(hex_timestamp, oldest_ts); WT_RET_MSG(session, EINVAL, "%s timestamp %.*s older than oldest timestamp %s", name, (int)cval->len, cval->str, hex_timestamp); } - if (has_stable_ts && __wt_timestamp_cmp(ts, &stable_ts) < 0) { - WT_RET(__wt_timestamp_to_hex_string(session, hex_timestamp, - &stable_ts)); + if (has_stable_ts && ts < stable_ts) { + __wt_timestamp_to_hex_string(hex_timestamp, stable_ts); WT_RET_MSG(session, EINVAL, "%s timestamp %.*s older than stable timestamp %s", name, (int)cval->len, cval->str, hex_timestamp); @@ -716,9 +606,9 @@ __wt_timestamp_validate(WT_SESSION_IMPL *session, const char *name, * commit timestamp. */ if (F_ISSET(txn, WT_TXN_HAS_TS_COMMIT) && - __wt_timestamp_cmp(ts, &txn->first_commit_timestamp) < 0) { - WT_RET(__wt_timestamp_to_hex_string( - session, hex_timestamp, &txn->first_commit_timestamp)); + ts < txn->first_commit_timestamp) { + __wt_timestamp_to_hex_string( + hex_timestamp, txn->first_commit_timestamp); WT_RET_MSG(session, EINVAL, "%s timestamp %.*s older than the first " "commit timestamp %s for this transaction", @@ -730,10 +620,9 @@ __wt_timestamp_validate(WT_SESSION_IMPL *session, const char *name, * Return an error if the given timestamp is older than the prepare * timestamp. */ - if (F_ISSET(txn, WT_TXN_PREPARE) && - __wt_timestamp_cmp(ts, &txn->prepare_timestamp) < 0) { - WT_RET(__wt_timestamp_to_hex_string( - session, hex_timestamp, &txn->prepare_timestamp)); + if (F_ISSET(txn, WT_TXN_PREPARE) && ts < txn->prepare_timestamp) { + __wt_timestamp_to_hex_string( + hex_timestamp, txn->prepare_timestamp); WT_RET_MSG(session, EINVAL, "%s timestamp %.*s older than the prepare timestamp %s " "for this transaction", @@ -742,7 +631,6 @@ __wt_timestamp_validate(WT_SESSION_IMPL *session, const char *name, return (0); } -#endif /* * __wt_txn_set_timestamp -- @@ -753,24 +641,20 @@ __wt_txn_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) { WT_CONFIG_ITEM cval; WT_DECL_RET; + WT_TXN *txn; + wt_timestamp_t ts; + + txn = &session->txn; /* Look for a commit timestamp. */ ret = __wt_config_gets_def(session, cfg, "commit_timestamp", 0, &cval); WT_RET_NOTFOUND_OK(ret); if (ret == 0 && cval.len != 0) { -#ifdef HAVE_TIMESTAMPS - WT_TXN *txn = &session->txn; - wt_timestamp_t ts; - WT_TRET(__wt_txn_context_check(session, true)); WT_RET(__wt_txn_parse_timestamp(session, "commit", &ts, &cval)); - WT_RET(__wt_timestamp_validate(session, "commit", &ts, &cval)); - __wt_timestamp_set(&txn->commit_timestamp, &ts); + WT_RET(__wt_timestamp_validate(session, "commit", ts, &cval)); + txn->commit_timestamp = ts; __wt_txn_set_commit_timestamp(session); -#else - WT_RET_MSG(session, ENOTSUP, "commit_timestamp requires a " - "version of WiredTiger built with timestamp support"); -#endif } else /* * We allow setting the commit timestamp after a prepare @@ -793,18 +677,16 @@ __wt_txn_parse_prepare_timestamp( WT_SESSION_IMPL *session, const char *cfg[], wt_timestamp_t *timestamp) { WT_CONFIG_ITEM cval; + WT_TXN *prev; + WT_TXN_GLOBAL *txn_global; + wt_timestamp_t oldest_ts; + char hex_timestamp[WT_TS_HEX_SIZE]; + + txn_global = &S2C(session)->txn_global; WT_RET(__wt_config_gets_def(session, cfg, "prepare_timestamp", 0, &cval)); if (cval.len > 0) { -#ifdef HAVE_TIMESTAMPS - WT_TXN *prev; - WT_TXN_GLOBAL *txn_global; - wt_timestamp_t oldest_ts; - char hex_timestamp[2 * WT_TIMESTAMP_SIZE + 1]; - - txn_global = &S2C(session)->txn_global; - if (F_ISSET(&session->txn, WT_TXN_HAS_TS_COMMIT)) WT_RET_MSG(session, EINVAL, "commit timestamp should not have been set before " @@ -829,12 +711,11 @@ __wt_txn_parse_prepare_timestamp( prev, __wt_txn_rts_qh, read_timestampq); continue; } - if (__wt_timestamp_cmp( - &prev->read_timestamp, timestamp) >= 0) { + if (prev->read_timestamp >= *timestamp) { __wt_readunlock(session, &txn_global->read_timestamp_rwlock); - WT_RET(__wt_timestamp_to_hex_string(session, - hex_timestamp, &prev->read_timestamp)); + __wt_timestamp_to_hex_string( + hex_timestamp, prev->read_timestamp); WT_RET_MSG(session, EINVAL, "prepare timestamp %.*s not later than " "an active read timestamp %s ", @@ -849,24 +730,17 @@ __wt_txn_parse_prepare_timestamp( * be older than oldest timestamp. */ if (prev == NULL) { - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - __wt_timestamp_set(&oldest_ts, - &txn_global->oldest_timestamp)); + oldest_ts = txn_global->oldest_timestamp; - if (__wt_timestamp_cmp(timestamp, &oldest_ts) < 0) { - WT_RET(__wt_timestamp_to_hex_string(session, - hex_timestamp, &oldest_ts)); + if (*timestamp < oldest_ts) { + __wt_timestamp_to_hex_string( + hex_timestamp, oldest_ts); WT_RET_MSG(session, EINVAL, "prepare timestamp %.*s is older than the " "oldest timestamp %s ", (int)cval.len, cval.str, hex_timestamp); } } -#else - WT_UNUSED(timestamp); - WT_RET_MSG(session, EINVAL, "prepare_timestamp requires a " - "version of WiredTiger built with timestamp support"); -#endif } else WT_RET_MSG(session, EINVAL, "prepare timestamp is required"); @@ -881,17 +755,15 @@ __wt_txn_parse_read_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) { WT_CONFIG_ITEM cval; WT_TXN *txn; + WT_TXN_GLOBAL *txn_global; + wt_timestamp_t ts; + char hex_timestamp[2][WT_TS_HEX_SIZE]; + bool round_to_oldest; txn = &session->txn; WT_RET(__wt_config_gets_def(session, cfg, "read_timestamp", 0, &cval)); if (cval.len > 0) { -#ifdef HAVE_TIMESTAMPS - wt_timestamp_t ts; - WT_TXN_GLOBAL *txn_global; - char hex_timestamp[2][2 * WT_TIMESTAMP_SIZE + 1]; - bool round_to_oldest; - txn_global = &S2C(session)->txn_global; WT_RET(__wt_txn_parse_timestamp(session, "read", &ts, &cval)); @@ -920,21 +792,19 @@ __wt_txn_parse_read_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) * avoid a race between checking and setting transaction * timestamp. */ - WT_RET(__wt_timestamp_to_hex_string(session, - hex_timestamp[0], &ts)); + __wt_timestamp_to_hex_string(hex_timestamp[0], ts); __wt_readlock(session, &txn_global->rwlock); - if (__wt_timestamp_cmp( - &ts, &txn_global->oldest_timestamp) < 0) { - WT_RET(__wt_timestamp_to_hex_string(session, - hex_timestamp[1], &txn_global->oldest_timestamp)); + if (ts < txn_global->oldest_timestamp) { + __wt_timestamp_to_hex_string( + hex_timestamp[1], txn_global->oldest_timestamp); /* * If given read timestamp is earlier than oldest * timestamp then round the read timestamp to * oldest timestamp. */ if (round_to_oldest) - __wt_timestamp_set(&txn->read_timestamp, - &txn_global->oldest_timestamp); + txn->read_timestamp = + txn_global->oldest_timestamp; else { __wt_readunlock(session, &txn_global->rwlock); WT_RET_MSG(session, EINVAL, "read timestamp " @@ -942,7 +812,7 @@ __wt_txn_parse_read_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) hex_timestamp[0], hex_timestamp[1]); } } else { - __wt_timestamp_set(&txn->read_timestamp, &ts); + txn->read_timestamp = ts; /* * Reset to avoid a verbose message as read * timestamp is not rounded to oldest timestamp. @@ -969,18 +839,11 @@ __wt_txn_parse_read_timestamp(WT_SESSION_IMPL *session, const char *cfg[]) */ if (F_ISSET(txn, WT_TXN_RUNNING)) __wt_txn_get_snapshot(session); - -#else - WT_UNUSED(txn); - WT_RET_MSG(session, EINVAL, "read_timestamp requires a " - "version of WiredTiger built with timestamp support"); -#endif } return (0); } -#ifdef HAVE_TIMESTAMPS /* * __wt_txn_set_commit_timestamp -- * Publish a transaction's commit timestamp. @@ -1004,7 +867,7 @@ __wt_txn_set_commit_timestamp(WT_SESSION_IMPL *session) * transaction is running) into the first_commit_timestamp, which is * fixed. */ - __wt_timestamp_set(&ts, &txn->commit_timestamp); + ts = txn->commit_timestamp; __wt_writelock(session, &txn_global->commit_timestamp_rwlock); /* @@ -1052,8 +915,7 @@ __wt_txn_set_commit_timestamp(WT_SESSION_IMPL *session) */ qtxn = TAILQ_LAST( &txn_global->commit_timestamph, __wt_txn_cts_qh); - while (qtxn != NULL && __wt_timestamp_cmp( - &qtxn->first_commit_timestamp, &ts) > 0) { + while (qtxn != NULL && qtxn->first_commit_timestamp > ts) { ++walked; qtxn = TAILQ_PREV( qtxn, __wt_txn_cts_qh, commit_timestampq); @@ -1067,7 +929,7 @@ __wt_txn_set_commit_timestamp(WT_SESSION_IMPL *session) qtxn, txn, commit_timestampq); WT_STAT_CONN_INCRV(session, txn_commit_queue_walked, walked); } - __wt_timestamp_set(&txn->first_commit_timestamp, &ts); + txn->first_commit_timestamp = ts; ++txn_global->commit_timestampq_len; WT_STAT_CONN_INCR(session, txn_commit_queue_inserts); txn->clear_commit_q = false; @@ -1162,8 +1024,7 @@ __wt_txn_set_read_timestamp(WT_SESSION_IMPL *session) qtxn = TAILQ_LAST( &txn_global->read_timestamph, __wt_txn_rts_qh); while (qtxn != NULL && - __wt_timestamp_cmp(&qtxn->read_timestamp, - &txn->read_timestamp) > 0) { + qtxn->read_timestamp > txn->read_timestamp) { ++walked; qtxn = TAILQ_PREV( qtxn, __wt_txn_rts_qh, read_timestampq); @@ -1209,10 +1070,8 @@ __wt_txn_clear_read_timestamp(WT_SESSION_IMPL *session) wt_timestamp_t pinned_ts; txn_global = &S2C(session)->txn_global; - WT_WITH_TIMESTAMP_READLOCK(session, &txn_global->rwlock, - __wt_timestamp_set(&pinned_ts, &txn_global->pinned_timestamp)); - WT_ASSERT(session, - __wt_timestamp_cmp(&txn->read_timestamp, &pinned_ts) >= 0); + pinned_ts = txn_global->pinned_timestamp; + WT_ASSERT(session, txn->read_timestamp >= pinned_ts); } #endif flags = txn->flags; @@ -1226,7 +1085,6 @@ __wt_txn_clear_read_timestamp(WT_SESSION_IMPL *session) WT_PUBLISH(txn->clear_read_q, true); WT_PUBLISH(txn->flags, flags); } -#endif /* * __wt_txn_clear_timestamp_queues -- |