summaryrefslogtreecommitdiff
path: root/src/third_party
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2019-03-18 13:29:52 +1100
committerLuke Chen <luke.chen@mongodb.com>2019-03-18 13:29:52 +1100
commit6af32a3527aee45652a7765bff1d8222efe97756 (patch)
treed912721984372c6e9d00cc309d4877083280135f /src/third_party
parent564cfd0ede845a9c20280a352c544b36f6b74471 (diff)
downloadmongo-6af32a3527aee45652a7765bff1d8222efe97756.tar.gz
Import wiredtiger: bb36cf83cd952262af49a589d15940a8c865174c from branch mongodb-4.2
ref: 82c3f83aca..bb36cf83cd for: 4.1.10 WT-4618 Don't hijack other sessions in __wt_verbose_dump_txn WT-4620 Assert a uint64_t can hold a time_t, maintain seconds as uint64_t WT-4627 Coverity #111405: out-of-bounds overrun WT-4628 Don't reopens the tracking file on each call in test-utility-progress function WT-4638 Remove legacy variables from the __wt_cache structure WT-4641 Return errors when test/format verify failures
Diffstat (limited to 'src/third_party')
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/btree/bt_debug.c24
-rw-r--r--src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c2
-rw-r--r--src/third_party/wiredtiger/src/cache/cache_las.c6
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_sweep.c11
-rw-r--r--src/third_party/wiredtiger/src/evict/evict_lru.c8
-rw-r--r--src/third_party/wiredtiger/src/include/cache.h2
-rw-r--r--src/third_party/wiredtiger/src/include/dhandle.h2
-rw-r--r--src/third_party/wiredtiger/src/include/extern.h4
-rw-r--r--src/third_party/wiredtiger/src/include/meta.h2
-rw-r--r--src/third_party/wiredtiger/src/include/os_windows.h3
-rw-r--r--src/third_party/wiredtiger/src/include/session.h4
-rw-r--r--src/third_party/wiredtiger/src/include/verify_build.h6
-rw-r--r--src/third_party/wiredtiger/src/meta/meta_ckpt.c16
-rw-r--r--src/third_party/wiredtiger/src/session/session_api.c4
-rw-r--r--src/third_party/wiredtiger/src/session/session_dhandle.c7
-rw-r--r--src/third_party/wiredtiger/src/support/time.c9
-rw-r--r--src/third_party/wiredtiger/src/txn/txn.c26
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_recover.c3
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_timestamp.c61
-rw-r--r--src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c36
-rw-r--r--src/third_party/wiredtiger/test/utility/misc.c21
-rw-r--r--src/third_party/wiredtiger/test/utility/test_util.h5
23 files changed, 116 insertions, 148 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 23d74cd8a2f..933bc76bbff 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -1,5 +1,5 @@
{
- "commit": "82c3f83acae289e0ada5ab4e7fe549e47af1078e",
+ "commit": "bb36cf83cd952262af49a589d15940a8c865174c",
"github": "wiredtiger/wiredtiger.git",
"vendor": "wiredtiger",
"branch": "mongodb-4.2"
diff --git a/src/third_party/wiredtiger/src/btree/bt_debug.c b/src/third_party/wiredtiger/src/btree/bt_debug.c
index 29c784c4198..8d1ed01377c 100644
--- a/src/third_party/wiredtiger/src/btree/bt_debug.c
+++ b/src/third_party/wiredtiger/src/btree/bt_debug.c
@@ -1207,15 +1207,12 @@ __debug_update(WT_DBG *ds, WT_UPDATE *upd, bool hexbyte)
else
WT_RET(ds->f(ds, "\t" "txn id %" PRIu64, upd->txnid));
- __wt_timestamp_to_string(
- upd->start_ts, ts_string, sizeof(ts_string));
+ __wt_timestamp_to_string(upd->start_ts, ts_string);
WT_RET(ds->f(ds, ", start_ts %s", ts_string));
- __wt_timestamp_to_string(
- upd->stop_ts, ts_string, sizeof(ts_string));
+ __wt_timestamp_to_string(upd->stop_ts, ts_string);
WT_RET(ds->f(ds, ", stop_ts %s", ts_string));
if (upd->durable_ts != WT_TS_NONE) {
- __wt_timestamp_to_string(upd->durable_ts,
- ts_string, sizeof(ts_string));
+ __wt_timestamp_to_string(upd->durable_ts, ts_string);
WT_RET(ds->f(ds, ", durable-ts %s", ts_string));
}
@@ -1341,12 +1338,9 @@ __debug_cell(WT_DBG *ds, const WT_PAGE_HEADER *dsk, WT_CELL_UNPACK *unpack)
case WT_CELL_ADDR_INT:
case WT_CELL_ADDR_LEAF:
case WT_CELL_ADDR_LEAF_NO:
- __wt_timestamp_to_string(unpack->oldest_start_ts,
- ts_string[0], sizeof(ts_string[0]));
- __wt_timestamp_to_string(unpack->newest_start_ts,
- ts_string[1], sizeof(ts_string[1]));
- __wt_timestamp_to_string(unpack->newest_stop_ts,
- ts_string[2], sizeof(ts_string[2]));
+ __wt_timestamp_to_string(unpack->oldest_start_ts, ts_string[0]);
+ __wt_timestamp_to_string(unpack->newest_start_ts, ts_string[1]);
+ __wt_timestamp_to_string(unpack->newest_stop_ts, ts_string[2]);
WT_RET(ds->f(ds,
", ts %s,%s,%s", ts_string[0], ts_string[1], ts_string[2]));
break;
@@ -1356,10 +1350,8 @@ __debug_cell(WT_DBG *ds, const WT_PAGE_HEADER *dsk, WT_CELL_UNPACK *unpack)
case WT_CELL_VALUE_OVFL:
case WT_CELL_VALUE_OVFL_RM:
case WT_CELL_VALUE_SHORT:
- __wt_timestamp_to_string(unpack->start_ts,
- ts_string[0], sizeof(ts_string[0]));
- __wt_timestamp_to_string(unpack->stop_ts,
- ts_string[1], sizeof(ts_string[1]));
+ __wt_timestamp_to_string(unpack->start_ts, ts_string[0]);
+ __wt_timestamp_to_string(unpack->stop_ts, ts_string[1]);
WT_RET(ds->f(ds, ", ts %s-%s", ts_string[0], ts_string[1]));
break;
}
diff --git a/src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c b/src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c
index 82045edea31..844da3f041b 100644
--- a/src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c
+++ b/src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c
@@ -39,7 +39,7 @@ static int __verify_dsk_row(
else \
__wt_err(session, ret, __VA_ARGS__); \
} \
- return ((ret) == 0 ? ret : WT_ERROR); \
+ return ((ret) == 0 ? WT_ERROR : ret); \
} while (0)
#define WT_RET_VRFY(session, ...) \
diff --git a/src/third_party/wiredtiger/src/cache/cache_las.c b/src/third_party/wiredtiger/src/cache/cache_las.c
index 4ade406c619..d7175c32275 100644
--- a/src/third_party/wiredtiger/src/cache/cache_las.c
+++ b/src/third_party/wiredtiger/src/cache/cache_las.c
@@ -582,11 +582,9 @@ __las_insert_block_verbose(
(void)__wt_eviction_clean_needed(session, &pct_full);
(void)__wt_eviction_dirty_needed(session, &pct_dirty);
__wt_timestamp_to_string(
- multi->page_las.unstable_timestamp,
- ts_string[0], sizeof(ts_string));
+ multi->page_las.unstable_timestamp, ts_string[0]);
__wt_timestamp_to_string(
- multi->page_las.unstable_durable_timestamp,
- ts_string[1], sizeof(ts_string));
+ multi->page_las.unstable_durable_timestamp, ts_string[1]);
__wt_verbose(session,
WT_VERB_LOOKASIDE | WT_VERB_LOOKASIDE_ACTIVITY,
diff --git a/src/third_party/wiredtiger/src/conn/conn_sweep.c b/src/third_party/wiredtiger/src/conn/conn_sweep.c
index 673f7c81399..d07d32c41c9 100644
--- a/src/third_party/wiredtiger/src/conn/conn_sweep.c
+++ b/src/third_party/wiredtiger/src/conn/conn_sweep.c
@@ -18,7 +18,7 @@
* handles.
*/
static void
-__sweep_mark(WT_SESSION_IMPL *session, time_t now)
+__sweep_mark(WT_SESSION_IMPL *session, uint64_t now)
{
WT_CONNECTION_IMPL *conn;
WT_DATA_HANDLE *dhandle;
@@ -107,7 +107,7 @@ err: __wt_writeunlock(session, &dhandle->rwlock);
* until we have reached the configured minimum number of handles.
*/
static int
-__sweep_expire(WT_SESSION_IMPL *session, time_t now)
+__sweep_expire(WT_SESSION_IMPL *session, uint64_t now)
{
WT_CONNECTION_IMPL *conn;
WT_DATA_HANDLE *dhandle;
@@ -127,8 +127,7 @@ __sweep_expire(WT_SESSION_IMPL *session, time_t now)
!F_ISSET(dhandle, WT_DHANDLE_OPEN) ||
dhandle->session_inuse != 0 ||
dhandle->timeofdeath == 0 ||
- difftime(now, dhandle->timeofdeath) <=
- conn->sweep_idle_time)
+ now - dhandle->timeofdeath <= conn->sweep_idle_time)
continue;
/*
@@ -277,7 +276,7 @@ __sweep_server(void *arg)
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
WT_SESSION_IMPL *session;
- time_t last, now;
+ uint64_t last, now;
uint64_t last_las_sweep_id, min_sleep, oldest_id, sweep_interval;
u_int dead_handles;
@@ -340,7 +339,7 @@ __sweep_server(void *arg)
* less frequently than the lookaside table by default and the
* frequency is controlled by a user setting.
*/
- if ((uint64_t)(now - last) < sweep_interval)
+ if (now - last < sweep_interval)
continue;
WT_STAT_CONN_INCR(session, dh_sweeps);
/*
diff --git a/src/third_party/wiredtiger/src/evict/evict_lru.c b/src/third_party/wiredtiger/src/evict/evict_lru.c
index 1dc54d66382..331f1a6a219 100644
--- a/src/third_party/wiredtiger/src/evict/evict_lru.c
+++ b/src/third_party/wiredtiger/src/evict/evict_lru.c
@@ -2291,13 +2291,11 @@ __evict_page(WT_SESSION_IMPL *session, bool is_server)
* An internal session flags either the server itself or an eviction
* worker thread.
*/
- if (is_server) {
+ if (is_server)
WT_STAT_CONN_INCR(session, cache_eviction_server_evicting);
- cache->server_evicts++;
- } else if (F_ISSET(session, WT_SESSION_INTERNAL)) {
+ else if (F_ISSET(session, WT_SESSION_INTERNAL))
WT_STAT_CONN_INCR(session, cache_eviction_worker_evicting);
- cache->worker_evicts++;
- } else {
+ else {
if (__wt_page_is_modified(ref->page))
WT_STAT_CONN_INCR(session, cache_eviction_app_dirty);
WT_STAT_CONN_INCR(session, cache_eviction_app);
diff --git a/src/third_party/wiredtiger/src/include/cache.h b/src/third_party/wiredtiger/src/include/cache.h
index c4a276ca4d3..7ea2949f7bf 100644
--- a/src/third_party/wiredtiger/src/include/cache.h
+++ b/src/third_party/wiredtiger/src/include/cache.h
@@ -90,8 +90,6 @@ struct __wt_cache {
uint64_t app_waits; /* User threads waited for cache */
uint64_t app_evicts; /* Pages evicted by user threads */
- uint64_t server_evicts; /* Pages evicted by server thread */
- uint64_t worker_evicts; /* Pages evicted by worker threads */
uint64_t evict_max_page_size; /* Largest page seen at eviction */
struct timespec stuck_time; /* Stuck time */
diff --git a/src/third_party/wiredtiger/src/include/dhandle.h b/src/third_party/wiredtiger/src/include/dhandle.h
index 90cccb85be6..c6518a715f3 100644
--- a/src/third_party/wiredtiger/src/include/dhandle.h
+++ b/src/third_party/wiredtiger/src/include/dhandle.h
@@ -84,7 +84,7 @@ struct __wt_data_handle {
uint32_t session_ref; /* Sessions referencing this handle */
int32_t session_inuse; /* Sessions using this handle */
uint32_t excl_ref; /* Refs of handle by excl_session */
- time_t timeofdeath; /* Use count went to 0 */
+ uint64_t timeofdeath; /* Use count went to 0 */
WT_SESSION_IMPL *excl_session; /* Session with exclusive use, if any */
WT_DATA_SOURCE *dsrc; /* Data source for this handle */
diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h
index f550f00a88c..777e4d2db3a 100644
--- a/src/third_party/wiredtiger/src/include/extern.h
+++ b/src/third_party/wiredtiger/src/include/extern.h
@@ -803,7 +803,7 @@ extern int __wt_thread_group_destroy(WT_SESSION_IMPL *session, WT_THREAD_GROUP *
extern void __wt_thread_group_start_one(WT_SESSION_IMPL *session, WT_THREAD_GROUP *group, bool is_locked);
extern void __wt_thread_group_stop_one(WT_SESSION_IMPL *session, WT_THREAD_GROUP *group);
extern void __wt_epoch(WT_SESSION_IMPL *session, struct timespec *tsp) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default")));
-extern void __wt_seconds(WT_SESSION_IMPL *session, time_t *timep);
+extern void __wt_seconds(WT_SESSION_IMPL *session, uint64_t *secondsp) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default")));
extern uint64_t __wt_clock_to_nsec(uint64_t end, uint64_t begin);
extern void __wt_txn_release_snapshot(WT_SESSION_IMPL *session);
extern void __wt_txn_get_snapshot(WT_SESSION_IMPL *session);
@@ -852,7 +852,7 @@ extern int __wt_txn_named_snapshot_config(WT_SESSION_IMPL *session, const char *
extern void __wt_txn_named_snapshot_destroy(WT_SESSION_IMPL *session);
extern int __wt_txn_recover(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_txn_rollback_to_stable(WT_SESSION_IMPL *session, const char *cfg[]) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
-extern void __wt_timestamp_to_string(wt_timestamp_t ts, char *ts_string, size_t len);
+extern void __wt_timestamp_to_string(wt_timestamp_t ts, char *ts_string);
extern void __wt_timestamp_to_hex_string(wt_timestamp_t ts, char *hex_timestamp);
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));
diff --git a/src/third_party/wiredtiger/src/include/meta.h b/src/third_party/wiredtiger/src/include/meta.h
index 063732161dd..b1f9a557934 100644
--- a/src/third_party/wiredtiger/src/include/meta.h
+++ b/src/third_party/wiredtiger/src/include/meta.h
@@ -70,7 +70,7 @@ struct __wt_ckpt {
int64_t order; /* Checkpoint order */
- uintmax_t sec; /* Wall clock time */
+ uint64_t sec; /* Wall clock time */
uint64_t size; /* Checkpoint size */
diff --git a/src/third_party/wiredtiger/src/include/os_windows.h b/src/third_party/wiredtiger/src/include/os_windows.h
index dd377d0bcde..84619f218a2 100644
--- a/src/third_party/wiredtiger/src/include/os_windows.h
+++ b/src/third_party/wiredtiger/src/include/os_windows.h
@@ -54,8 +54,5 @@ typedef unsigned long u_long;
typedef int ssize_t;
#endif
-/* Provide a custom version of localtime_r */
-struct tm *localtime_r(const time_t* timer, struct tm* result);
-
/* Windows does not provide fsync */
#define fsync _commit
diff --git a/src/third_party/wiredtiger/src/include/session.h b/src/third_party/wiredtiger/src/include/session.h
index f7b41bc7784..0d99b4cc6e0 100644
--- a/src/third_party/wiredtiger/src/include/session.h
+++ b/src/third_party/wiredtiger/src/include/session.h
@@ -75,13 +75,13 @@ struct __wt_session_impl {
*/
/* Session handle reference list */
TAILQ_HEAD(__dhandles, __wt_data_handle_cache) dhandles;
- time_t last_sweep; /* Last sweep for dead handles */
+ uint64_t last_sweep; /* Last sweep for dead handles */
struct timespec last_epoch; /* Last epoch time returned */
WT_CURSOR_LIST cursors; /* Cursors closed with the session */
uint32_t cursor_sweep_position; /* Position in cursor_cache for sweep */
uint32_t cursor_sweep_countdown;/* Countdown to cursor sweep */
- time_t last_cursor_sweep; /* Last sweep for dead cursors */
+ uint64_t last_cursor_sweep; /* Last sweep for dead cursors */
WT_CURSOR_BACKUP *bkp_cursor; /* Hot backup cursor */
diff --git a/src/third_party/wiredtiger/src/include/verify_build.h b/src/third_party/wiredtiger/src/include/verify_build.h
index 558579482a2..dc085826241 100644
--- a/src/third_party/wiredtiger/src/include/verify_build.h
+++ b/src/third_party/wiredtiger/src/include/verify_build.h
@@ -84,4 +84,10 @@ __wt_verify_build(void)
* disallow them for now.
*/
WT_STATIC_ASSERT(sizeof(wt_off_t) == 8);
+
+ /*
+ * We require a time_t be an integral type and fit into a uint64_t for
+ * simplicity.
+ */
+ WT_STATIC_ASSERT(sizeof(time_t) <= sizeof(uint64_t));
}
diff --git a/src/third_party/wiredtiger/src/meta/meta_ckpt.c b/src/third_party/wiredtiger/src/meta/meta_ckpt.c
index d42d902d0a4..58711cc4e92 100644
--- a/src/third_party/wiredtiger/src/meta/meta_ckpt.c
+++ b/src/third_party/wiredtiger/src/meta/meta_ckpt.c
@@ -341,7 +341,7 @@ __ckpt_load(WT_SESSION_IMPL *session,
memcpy(timebuf, a.str, a.len);
timebuf[a.len] = '\0';
/* NOLINTNEXTLINE(cert-err34-c) */
- if (sscanf(timebuf, "%" SCNuMAX, &ckpt->sec) != 1)
+ if (sscanf(timebuf, "%" SCNu64, &ckpt->sec) != 1)
goto format;
WT_RET(__wt_config_subgets(session, v, "size", &a));
@@ -385,7 +385,6 @@ __wt_meta_ckptlist_set(WT_SESSION_IMPL *session,
WT_CKPT *ckpt;
WT_DECL_ITEM(buf);
WT_DECL_RET;
- time_t secs;
int64_t maxorder;
const char *sep;
@@ -431,14 +430,7 @@ __wt_meta_ckptlist_set(WT_SESSION_IMPL *session,
if (F_ISSET(ckpt, WT_CKPT_ADD))
ckpt->order = ++maxorder;
- /*
- * XXX
- * Assumes a time_t fits into a uintmax_t, which isn't
- * guaranteed, a time_t has to be an arithmetic type,
- * but not an integral type.
- */
- __wt_seconds(session, &secs);
- ckpt->sec = (uintmax_t)secs;
+ __wt_seconds(session, &ckpt->sec);
}
__wt_timestamp_addr_check(session, ckpt->oldest_start_ts,
@@ -457,7 +449,7 @@ __wt_meta_ckptlist_set(WT_SESSION_IMPL *session,
*/
WT_ERR(__wt_buf_catfmt(session, buf,
"=(addr=\"%.*s\",order=%" PRId64
- ",time=%" PRId64
+ ",time=%" PRIu64
",size=%" PRId64
",oldest_start_ts=%" PRId64
",newest_start_ts=%" PRId64
@@ -465,7 +457,7 @@ __wt_meta_ckptlist_set(WT_SESSION_IMPL *session,
",write_gen=%" PRId64 ")",
(int)ckpt->addr.size, (char *)ckpt->addr.data,
ckpt->order,
- (int64_t)ckpt->sec,
+ ckpt->sec,
(int64_t)ckpt->size,
(int64_t)ckpt->oldest_start_ts,
(int64_t)ckpt->newest_start_ts,
diff --git a/src/third_party/wiredtiger/src/session/session_api.c b/src/third_party/wiredtiger/src/session/session_api.c
index 379ec69c77d..7d3b4b9d81a 100644
--- a/src/third_party/wiredtiger/src/session/session_api.c
+++ b/src/third_party/wiredtiger/src/session/session_api.c
@@ -59,7 +59,7 @@ __wt_session_cursor_cache_sweep(WT_SESSION_IMPL *session)
WT_CURSOR *cursor, *cursor_tmp;
WT_CURSOR_LIST *cached_list;
WT_DECL_RET;
- time_t now;
+ uint64_t now;
uint32_t position;
int i, t_ret, nbuckets, nexamined, nclosed;
bool productive;
@@ -72,7 +72,7 @@ __wt_session_cursor_cache_sweep(WT_SESSION_IMPL *session)
* do it again.
*/
__wt_seconds(session, &now);
- if (difftime(now, session->last_cursor_sweep) < 1)
+ if (now - session->last_cursor_sweep < 1)
return (0);
session->last_cursor_sweep = now;
diff --git a/src/third_party/wiredtiger/src/session/session_dhandle.c b/src/third_party/wiredtiger/src/session/session_dhandle.c
index 3b5ab5bf1e9..a520049c353 100644
--- a/src/third_party/wiredtiger/src/session/session_dhandle.c
+++ b/src/third_party/wiredtiger/src/session/session_dhandle.c
@@ -392,7 +392,7 @@ __session_dhandle_sweep(WT_SESSION_IMPL *session)
WT_CONNECTION_IMPL *conn;
WT_DATA_HANDLE *dhandle;
WT_DATA_HANDLE_CACHE *dhandle_cache, *dhandle_cache_tmp;
- time_t now;
+ uint64_t now;
conn = S2C(session);
@@ -401,7 +401,7 @@ __session_dhandle_sweep(WT_SESSION_IMPL *session)
* do it again.
*/
__wt_seconds(session, &now);
- if (difftime(now, session->last_sweep) < conn->sweep_interval)
+ if (now - session->last_sweep < conn->sweep_interval)
return;
session->last_sweep = now;
@@ -414,8 +414,7 @@ __session_dhandle_sweep(WT_SESSION_IMPL *session)
dhandle->session_inuse == 0 &&
(WT_DHANDLE_INACTIVE(dhandle) ||
(dhandle->timeofdeath != 0 &&
- difftime(now, dhandle->timeofdeath) >
- conn->sweep_idle_time))) {
+ now - dhandle->timeofdeath > conn->sweep_idle_time))) {
WT_STAT_CONN_INCR(session, dh_session_handles);
WT_ASSERT(session, !WT_IS_METADATA(dhandle));
__session_discard_dhandle(session, dhandle_cache);
diff --git a/src/third_party/wiredtiger/src/support/time.c b/src/third_party/wiredtiger/src/support/time.c
index ccc8284ef08..d6ad80f07dc 100644
--- a/src/third_party/wiredtiger/src/support/time.c
+++ b/src/third_party/wiredtiger/src/support/time.c
@@ -63,13 +63,18 @@ __wt_epoch(WT_SESSION_IMPL *session, struct timespec *tsp)
* Return the seconds since the Epoch.
*/
void
-__wt_seconds(WT_SESSION_IMPL *session, time_t *timep)
+__wt_seconds(WT_SESSION_IMPL *session, uint64_t *secondsp)
+ WT_GCC_FUNC_ATTRIBUTE((visibility("default")))
{
struct timespec t;
__wt_epoch(session, &t);
- *timep = t.tv_sec;
+ /*
+ * A time_t isn't guaranteed to fit into a uint64_t, but it's asserted
+ * when WiredTiger builds.
+ */
+ *secondsp = (uint64_t)t.tv_sec;
}
/*
diff --git a/src/third_party/wiredtiger/src/txn/txn.c b/src/third_party/wiredtiger/src/txn/txn.c
index 8c5d7ffb826..1482e02c7ea 100644
--- a/src/third_party/wiredtiger/src/txn/txn.c
+++ b/src/third_party/wiredtiger/src/txn/txn.c
@@ -1500,14 +1500,10 @@ __wt_verbose_dump_txn_one(WT_SESSION_IMPL *session, WT_TXN *txn)
iso_tag = "WT_ISO_SNAPSHOT";
break;
}
- __wt_timestamp_to_string(
- txn->commit_timestamp, ts_string[0], sizeof(ts_string[0]));
- __wt_timestamp_to_string(
- txn->durable_timestamp, ts_string[1], sizeof(ts_string[1]));
- __wt_timestamp_to_string(
- txn->first_commit_timestamp, ts_string[2], sizeof(ts_string[2]));
- __wt_timestamp_to_string(
- txn->read_timestamp, ts_string[3], sizeof(ts_string[3]));
+ __wt_timestamp_to_string(txn->commit_timestamp, ts_string[0]);
+ __wt_timestamp_to_string(txn->durable_timestamp, ts_string[1]);
+ __wt_timestamp_to_string(txn->first_commit_timestamp, ts_string[2]);
+ __wt_timestamp_to_string(txn->read_timestamp, ts_string[3]);
WT_RET(__wt_msg(session,
"mod count: %u"
", snap min: %" PRIu64
@@ -1558,17 +1554,13 @@ __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));
- __wt_timestamp_to_string(
- txn_global->commit_timestamp, ts_string, sizeof(ts_string));
+ __wt_timestamp_to_string(txn_global->commit_timestamp, ts_string);
WT_RET(__wt_msg(session, "commit timestamp: %s", ts_string));
- __wt_timestamp_to_string(
- txn_global->oldest_timestamp, ts_string, sizeof(ts_string));
+ __wt_timestamp_to_string(txn_global->oldest_timestamp, ts_string);
WT_RET(__wt_msg(session, "oldest timestamp: %s", ts_string));
- __wt_timestamp_to_string(
- txn_global->pinned_timestamp, ts_string, sizeof(ts_string));
+ __wt_timestamp_to_string(txn_global->pinned_timestamp, ts_string);
WT_RET(__wt_msg(session, "pinned timestamp: %s", ts_string));
- __wt_timestamp_to_string(
- txn_global->stable_timestamp, ts_string, sizeof(ts_string));
+ __wt_timestamp_to_string(txn_global->stable_timestamp, ts_string);
WT_RET(__wt_msg(session, "stable timestamp: %s", ts_string));
WT_RET(__wt_msg(session, "has_commit_timestamp: %s",
txn_global->has_commit_timestamp ? "yes" : "no"));
@@ -1618,7 +1610,7 @@ __wt_verbose_dump_txn(WT_SESSION_IMPL *session)
id, s->pinned_id, s->metadata_pinned,
sess->name == NULL ?
"EMPTY" : sess->name));
- WT_RET(__wt_verbose_dump_txn_one(sess, &sess->txn));
+ WT_RET(__wt_verbose_dump_txn_one(session, &sess->txn));
}
return (0);
diff --git a/src/third_party/wiredtiger/src/txn/txn_recover.c b/src/third_party/wiredtiger/src/txn/txn_recover.c
index 77eecbe2e84..c793e182eff 100644
--- a/src/third_party/wiredtiger/src/txn/txn_recover.c
+++ b/src/third_party/wiredtiger/src/txn/txn_recover.c
@@ -400,8 +400,7 @@ __recovery_set_checkpoint_timestamp(WT_RECOVERY *r)
if (WT_VERBOSE_ISSET(session,
WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS)) {
__wt_timestamp_to_string(
- conn->txn_global.recovery_timestamp,
- ts_string, sizeof(ts_string));
+ conn->txn_global.recovery_timestamp, ts_string);
__wt_verbose(session,
WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS,
"Set global recovery timestamp: %s", ts_string);
diff --git a/src/third_party/wiredtiger/src/txn/txn_timestamp.c b/src/third_party/wiredtiger/src/txn/txn_timestamp.c
index bf65db45153..0b9f790c1e6 100644
--- a/src/third_party/wiredtiger/src/txn/txn_timestamp.c
+++ b/src/third_party/wiredtiger/src/txn/txn_timestamp.c
@@ -19,9 +19,9 @@
* Convert a timestamp to the MongoDB string representation.
*/
void
-__wt_timestamp_to_string(wt_timestamp_t ts, char *ts_string, size_t len)
+__wt_timestamp_to_string(wt_timestamp_t ts, char *ts_string)
{
- WT_IGNORE_RET(__wt_snprintf(ts_string, len,
+ WT_IGNORE_RET(__wt_snprintf(ts_string, WT_TS_INT_STRING_SIZE,
"(%" PRIu32 ",%" PRIu32 ")",
(uint32_t)((ts >> 32) & 0xffffffff), (uint32_t)(ts & 0xffffffff)));
}
@@ -72,7 +72,7 @@ __wt_verbose_timestamp(
if (!WT_VERBOSE_ISSET(session, WT_VERB_TIMESTAMP))
return;
- __wt_timestamp_to_string(ts, ts_string, sizeof(ts_string));
+ __wt_timestamp_to_string(ts, ts_string);
__wt_verbose(session,
WT_VERB_TIMESTAMP, "Timestamp %s : %s", ts_string, msg);
}
@@ -481,10 +481,8 @@ __wt_txn_global_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[])
if (has_commit && (has_oldest ||
txn_global->has_oldest_timestamp) && oldest_ts > commit_ts) {
__wt_readunlock(session, &txn_global->rwlock);
- __wt_timestamp_to_string(
- oldest_ts, ts_string[0], sizeof(ts_string[0]));
- __wt_timestamp_to_string(
- commit_ts, ts_string[1], sizeof(ts_string[1]));
+ __wt_timestamp_to_string(oldest_ts, ts_string[0]);
+ __wt_timestamp_to_string(commit_ts, ts_string[1]);
WT_RET_MSG(session, EINVAL,
"set_timestamp: oldest timestamp %s must not be later than "
"commit timestamp %s", ts_string[0], ts_string[1]);
@@ -493,10 +491,8 @@ __wt_txn_global_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[])
if (has_commit && (has_stable ||
txn_global->has_stable_timestamp) && stable_ts > commit_ts) {
__wt_readunlock(session, &txn_global->rwlock);
- __wt_timestamp_to_string(
- stable_ts, ts_string[0], sizeof(ts_string[0]));
- __wt_timestamp_to_string(
- commit_ts, ts_string[1], sizeof(ts_string[1]));
+ __wt_timestamp_to_string(stable_ts, ts_string[0]);
+ __wt_timestamp_to_string(commit_ts, ts_string[1]);
WT_RET_MSG(session, EINVAL,
"set_timestamp: stable timestamp %s must not be later than "
"commit timestamp %s", ts_string[0], ts_string[1]);
@@ -511,10 +507,8 @@ __wt_txn_global_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[])
(has_stable ||
txn_global->has_stable_timestamp) && oldest_ts > stable_ts) {
__wt_readunlock(session, &txn_global->rwlock);
- __wt_timestamp_to_string(
- oldest_ts, ts_string[0], sizeof(ts_string[0]));
- __wt_timestamp_to_string(
- stable_ts, ts_string[1], sizeof(ts_string[1]));
+ __wt_timestamp_to_string(oldest_ts, ts_string[0]);
+ __wt_timestamp_to_string(stable_ts, ts_string[1]);
WT_RET_MSG(session, EINVAL,
"set_timestamp: oldest timestamp %s must not be later than "
"stable timestamp %s", ts_string[0], ts_string[1]);
@@ -613,15 +607,13 @@ __wt_txn_commit_timestamp_validate(WT_SESSION_IMPL *session, const char *name,
stable_ts = txn_global->stable_timestamp;
if (durable_ts && has_oldest_ts && ts < oldest_ts) {
- __wt_timestamp_to_string(
- oldest_ts, ts_string[0], sizeof(ts_string[0]));
+ __wt_timestamp_to_string(oldest_ts, ts_string[0]);
WT_RET_MSG(session, EINVAL,
"%s timestamp %.*s older than oldest timestamp %s",
name, (int)cval->len, cval->str, ts_string[0]);
}
if (durable_ts && has_stable_ts && ts < stable_ts) {
- __wt_timestamp_to_string(
- stable_ts, ts_string[0], sizeof(ts_string[0]));
+ __wt_timestamp_to_string(stable_ts, ts_string[0]);
WT_RET_MSG(session, EINVAL,
"%s timestamp %.*s older than stable timestamp %s",
name, (int)cval->len, cval->str, ts_string[0]);
@@ -634,8 +626,8 @@ __wt_txn_commit_timestamp_validate(WT_SESSION_IMPL *session, const char *name,
*/
if (F_ISSET(txn, WT_TXN_HAS_TS_COMMIT) &&
ts < txn->first_commit_timestamp) {
- __wt_timestamp_to_string(txn->first_commit_timestamp,
- ts_string[0], sizeof(ts_string[0]));
+ __wt_timestamp_to_string(
+ txn->first_commit_timestamp, ts_string[0]);
WT_RET_MSG(session, EINVAL,
"%s timestamp %.*s older than the first "
"commit timestamp %s for this transaction",
@@ -648,8 +640,7 @@ __wt_txn_commit_timestamp_validate(WT_SESSION_IMPL *session, const char *name,
* timestamp.
*/
if (F_ISSET(txn, WT_TXN_PREPARE) && ts < txn->prepare_timestamp) {
- __wt_timestamp_to_string(
- txn->prepare_timestamp, ts_string[0], sizeof(ts_string[0]));
+ __wt_timestamp_to_string(txn->prepare_timestamp, ts_string[0]);
WT_RET_MSG(session, EINVAL,
"%s timestamp %.*s older than the prepare timestamp %s "
"for this transaction",
@@ -658,10 +649,8 @@ __wt_txn_commit_timestamp_validate(WT_SESSION_IMPL *session, const char *name,
if (F_ISSET(txn, WT_TXN_HAS_TS_DURABLE) &&
txn->durable_timestamp < txn->commit_timestamp) {
- __wt_timestamp_to_string(
- txn->durable_timestamp, ts_string[0], sizeof(ts_string[0]));
- __wt_timestamp_to_string(
- txn->commit_timestamp, ts_string[1], sizeof(ts_string[1]));
+ __wt_timestamp_to_string(txn->durable_timestamp, ts_string[0]);
+ __wt_timestamp_to_string(txn->commit_timestamp, ts_string[1]);
WT_RET_MSG(session, EINVAL,
"%s timestamp %s older than the commit timestamp %s "
"for this transaction",
@@ -791,8 +780,8 @@ __wt_txn_parse_prepare_timestamp(
if (prev->read_timestamp >= *timestamp) {
__wt_readunlock(session,
&txn_global->read_timestamp_rwlock);
- __wt_timestamp_to_string(prev->read_timestamp,
- ts_string, sizeof(ts_string));
+ __wt_timestamp_to_string(
+ prev->read_timestamp, ts_string);
WT_RET_MSG(session, EINVAL,
"prepare timestamp %.*s not later than "
"an active read timestamp %s ",
@@ -810,8 +799,7 @@ __wt_txn_parse_prepare_timestamp(
oldest_ts = txn_global->oldest_timestamp;
if (*timestamp < oldest_ts) {
- __wt_timestamp_to_string(
- oldest_ts, ts_string, sizeof(ts_string));
+ __wt_timestamp_to_string(oldest_ts, ts_string);
WT_RET_MSG(session, EINVAL,
"prepare timestamp %.*s is older than the "
"oldest timestamp %s ", (int)cval.len,
@@ -882,10 +870,9 @@ __wt_txn_parse_read_timestamp(WT_SESSION_IMPL *session, const char *cfg[])
txn->read_timestamp = ts_oldest;
else {
__wt_readunlock(session, &txn_global->rwlock);
+ __wt_timestamp_to_string(ts, ts_string[0]);
__wt_timestamp_to_string(
- ts, ts_string[0], sizeof(ts_string[0]));
- __wt_timestamp_to_string(ts_oldest,
- ts_string[1], sizeof(ts_string[1]));
+ ts_oldest, ts_string[1]);
WT_RET_MSG(session, EINVAL, "read timestamp "
"%s older than oldest timestamp %s",
ts_string[0], ts_string[1]);
@@ -907,10 +894,8 @@ __wt_txn_parse_read_timestamp(WT_SESSION_IMPL *session, const char *cfg[])
* This message is generated here to reduce the span of
* critical section.
*/
- __wt_timestamp_to_string(
- ts, ts_string[0], sizeof(ts_string[0]));
- __wt_timestamp_to_string(
- ts_oldest, ts_string[1], sizeof(ts_string[1]));
+ __wt_timestamp_to_string(ts, ts_string[0]);
+ __wt_timestamp_to_string(ts_oldest, ts_string[1]);
__wt_verbose(session, WT_VERB_TIMESTAMP, "Read "
"timestamp %s : Rounded to oldest timestamp %s",
ts_string[0], ts_string[1]);
diff --git a/src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c b/src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c
index 80ed11556ff..1f14056eca1 100644
--- a/src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c
+++ b/src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c
@@ -46,7 +46,7 @@ static void *thread_insert(void *);
static void *thread_get(void *);
#define BLOOM false
-#define MAX_GAP 7.0
+#define MAX_GAP 7
#define N_RECORDS 10000
#define N_INSERT 1000000
#define N_INSERT_THREAD 1
@@ -207,21 +207,21 @@ thread_insert(void *arg)
WT_CURSOR *maincur;
WT_RAND_STATE rnd;
WT_SESSION *session;
- double elapsed;
- time_t prevtime, curtime; /* 1 second resolution is okay */
+ uint64_t curtime, elapsed, prevtime; /* 1 second resolution enough */
int bal, i, flag, key, post;
const char *extra = S1024;
threadargs = (THREAD_ARGS *)arg;
opts = threadargs->testopts;
- __wt_random_init_seed(NULL, &rnd);
- (void)time(&prevtime);
testutil_check(opts->conn->open_session(
opts->conn, NULL, NULL, &session));
- testutil_check(session->open_cursor(session, opts->uri, NULL, NULL,
- &maincur));
+ __wt_random_init_seed((WT_SESSION_IMPL *)session, &rnd);
+ __wt_seconds((WT_SESSION_IMPL *)session, &prevtime);
+
+ testutil_check(session->open_cursor(
+ session, opts->uri, NULL, NULL, &maincur));
testutil_progress(opts, "insert start");
for (i = 0; i < N_INSERT; i++) {
@@ -252,11 +252,11 @@ thread_insert(void *arg)
fprintf(stderr, "*");
else
fprintf(stderr, ".");
- (void)time(&curtime);
- if ((elapsed = difftime(curtime, prevtime)) > MAX_GAP) {
+ __wt_seconds((WT_SESSION_IMPL *)session, &curtime);
+ if ((elapsed = curtime - prevtime) > MAX_GAP) {
testutil_progress(opts, "insert time gap");
fprintf(stderr, "\n"
- "GAP: %.0f secs after %d inserts\n",
+ "GAP: %" PRIu64 " secs after %d inserts\n",
elapsed, i);
threadargs->nfail++;
}
@@ -277,21 +277,21 @@ thread_get(void *arg)
THREAD_ARGS *threadargs;
WT_CURSOR *maincur, *postcur;
WT_SESSION *session;
- double elapsed;
- time_t prevtime, curtime; /* 1 second resolution is okay */
+ uint64_t curtime, elapsed, prevtime; /* 1 second resolution enough */
int bal, bal2, flag, flag2, key, key2, post, post2;
char *extra;
threadargs = (THREAD_ARGS *)arg;
opts = threadargs->testopts;
sharedopts = threadargs->sharedopts;
- (void)time(&prevtime);
testutil_check(opts->conn->open_session(
opts->conn, NULL, NULL, &session));
- testutil_check(session->open_cursor(session, opts->uri, NULL, NULL,
- &maincur));
+ __wt_seconds((WT_SESSION_IMPL *)session, &prevtime);
+
+ testutil_check(session->open_cursor(
+ session, opts->uri, NULL, NULL, &maincur));
testutil_check(session->open_cursor(
session, sharedopts->posturi, NULL, NULL, &postcur));
@@ -325,11 +325,11 @@ thread_get(void *arg)
fprintf(stderr, "G");
testutil_check(session->rollback_transaction(session, NULL));
- (void)time(&curtime);
- if ((elapsed = difftime(curtime, prevtime)) > MAX_GAP) {
+ __wt_seconds((WT_SESSION_IMPL *)session, &curtime);
+ if ((elapsed = curtime - prevtime) > MAX_GAP) {
testutil_progress(opts, "get time gap");
fprintf(stderr, "\n"
- "GAP: %.0f secs after %d gets\n",
+ "GAP: %" PRIu64 " secs after %d gets\n",
elapsed, threadargs->njoins);
threadargs->nfail++;
}
diff --git a/src/third_party/wiredtiger/test/utility/misc.c b/src/third_party/wiredtiger/test/utility/misc.c
index d5166ace0b0..6ecf8513abd 100644
--- a/src/third_party/wiredtiger/test/utility/misc.c
+++ b/src/third_party/wiredtiger/test/utility/misc.c
@@ -163,14 +163,16 @@ void
testutil_progress(TEST_OPTS *opts, const char *message)
{
FILE *fp;
- time_t now;
-
- if ((fp = fopen(opts->progress_file_name, "a")) == NULL)
- testutil_die(errno, "fopen");
- (void)time(&now);
- fprintf(fp, "[%" PRIuMAX "] %s\n", (uintmax_t)now, message);
- if (fclose(fp) != 0)
- testutil_die(errno, "fclose");
+ uint64_t now;
+
+ if (opts->progress_fp == NULL)
+ testutil_assert((opts->progress_fp =
+ fopen(opts->progress_file_name, "w")) != NULL);
+
+ fp = opts->progress_fp;
+ __wt_seconds(NULL, &now);
+ testutil_assert(fprintf(fp, "[%" PRIu64 "] %s\n", now, message) >= 0);
+ testutil_assert(fflush(fp) == 0);
}
/*
@@ -186,6 +188,9 @@ testutil_cleanup(TEST_OPTS *opts)
if (!opts->preserve)
testutil_clean_work_dir(opts->home);
+ if (opts->progress_fp != NULL)
+ testutil_assert(fclose(opts->progress_fp) == 0);
+
free(opts->uri);
free(opts->progress_file_name);
free(opts->home);
diff --git a/src/third_party/wiredtiger/test/utility/test_util.h b/src/third_party/wiredtiger/test/utility/test_util.h
index 9213ed827e1..b77a4fe5b77 100644
--- a/src/third_party/wiredtiger/test/utility/test_util.h
+++ b/src/third_party/wiredtiger/test/utility/test_util.h
@@ -49,12 +49,15 @@
/* Generic option parsing structure shared by all test cases. */
typedef struct {
char *home;
- char *progress_file_name;
const char *progname;
enum { TABLE_COL=1, /* Fixed-length column store */
TABLE_FIX=2, /* Variable-length column store */
TABLE_ROW=3 /* Row-store */
} table_type;
+
+ FILE *progress_fp; /* Progress tracking file */
+ char *progress_file_name;
+
bool preserve; /* Don't remove files on exit */
bool verbose; /* Run in verbose mode */
bool do_data_ops; /* Have schema ops use data */