summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src')
-rw-r--r--src/third_party/wiredtiger/src/btree/bt_handle.c13
-rw-r--r--src/third_party/wiredtiger/src/btree/bt_walk.c15
-rw-r--r--src/third_party/wiredtiger/src/config/config_def.c3
-rw-r--r--src/third_party/wiredtiger/src/docs/transactions.dox3
-rw-r--r--src/third_party/wiredtiger/src/include/btree.h9
-rw-r--r--src/third_party/wiredtiger/src/include/optrack.h3
-rw-r--r--src/third_party/wiredtiger/src/include/txn.h5
-rw-r--r--src/third_party/wiredtiger/src/include/txn.i2
-rw-r--r--src/third_party/wiredtiger/src/optrack/optrack.c13
-rw-r--r--src/third_party/wiredtiger/src/support/hazard.c7
-rw-r--r--src/third_party/wiredtiger/src/txn/txn.c55
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_log.c6
12 files changed, 86 insertions, 48 deletions
diff --git a/src/third_party/wiredtiger/src/btree/bt_handle.c b/src/third_party/wiredtiger/src/btree/bt_handle.c
index 840e4fa5d2e..370e81673d8 100644
--- a/src/third_party/wiredtiger/src/btree/bt_handle.c
+++ b/src/third_party/wiredtiger/src/btree/bt_handle.c
@@ -400,13 +400,20 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt)
cfg, "assert.commit_timestamp", &cval));
if (WT_STRING_MATCH("always", cval.str, cval.len)) {
FLD_SET(btree->assert_flags, WT_ASSERT_COMMIT_TS_ALWAYS);
- FLD_CLR(btree->assert_flags, WT_ASSERT_COMMIT_TS_NEVER);
+ FLD_CLR(btree->assert_flags,
+ WT_ASSERT_COMMIT_TS_KEYS | WT_ASSERT_COMMIT_TS_NEVER);
+ } else if (WT_STRING_MATCH("key_consistent", cval.str, cval.len)) {
+ FLD_SET(btree->assert_flags, WT_ASSERT_COMMIT_TS_KEYS);
+ FLD_CLR(btree->assert_flags,
+ WT_ASSERT_COMMIT_TS_ALWAYS | WT_ASSERT_COMMIT_TS_NEVER);
} else if (WT_STRING_MATCH("never", cval.str, cval.len)) {
FLD_SET(btree->assert_flags, WT_ASSERT_COMMIT_TS_NEVER);
- FLD_CLR(btree->assert_flags, WT_ASSERT_COMMIT_TS_ALWAYS);
+ FLD_CLR(btree->assert_flags,
+ WT_ASSERT_COMMIT_TS_ALWAYS | WT_ASSERT_COMMIT_TS_KEYS);
} else
FLD_CLR(btree->assert_flags,
- WT_ASSERT_COMMIT_TS_ALWAYS | WT_ASSERT_COMMIT_TS_NEVER);
+ WT_ASSERT_COMMIT_TS_ALWAYS |
+ WT_ASSERT_COMMIT_TS_KEYS | WT_ASSERT_COMMIT_TS_NEVER);
WT_RET(__wt_config_gets(session, cfg, "assert.read_timestamp", &cval));
if (WT_STRING_MATCH("always", cval.str, cval.len)) {
FLD_SET(btree->assert_flags, WT_ASSERT_READ_TS_ALWAYS);
diff --git a/src/third_party/wiredtiger/src/btree/bt_walk.c b/src/third_party/wiredtiger/src/btree/bt_walk.c
index eef790d7459..22921d7d378 100644
--- a/src/third_party/wiredtiger/src/btree/bt_walk.c
+++ b/src/third_party/wiredtiger/src/btree/bt_walk.c
@@ -293,7 +293,7 @@ __tree_walk_internal(WT_SESSION_IMPL *session,
WT_DECL_RET;
WT_PAGE_INDEX *pindex;
WT_REF *couple, *couple_orig, *ref;
- uint32_t slot;
+ uint32_t current_state, slot;
bool empty_internal, initial_descent, prev, skip;
btree = S2BT(session);
@@ -460,7 +460,8 @@ restart: /*
* If we see any child states other than deleted, the
* page isn't empty.
*/
- if (ref->state != WT_REF_DELETED &&
+ current_state = ref->state;
+ if (current_state != WT_REF_DELETED &&
!LF_ISSET(WT_READ_TRUNCATE))
empty_internal = false;
@@ -470,12 +471,12 @@ restart: /*
* fast-path some common cases.
*/
if (LF_ISSET(WT_READ_NO_WAIT) &&
- ref->state != WT_REF_MEM &&
- ref->state != WT_REF_LIMBO)
+ current_state != WT_REF_MEM &&
+ current_state != WT_REF_LIMBO)
break;
/* Skip lookaside pages if not requested. */
- if (ref->state == WT_REF_LOOKASIDE &&
+ if (current_state == WT_REF_LOOKASIDE &&
!LF_ISSET(WT_READ_LOOKASIDE))
break;
} else if (LF_ISSET(WT_READ_TRUNCATE)) {
@@ -483,7 +484,7 @@ restart: /*
* Avoid pulling a deleted page back in to try
* to delete it again.
*/
- if (ref->state == WT_REF_DELETED &&
+ if (current_state == WT_REF_DELETED &&
__wt_delete_page_skip(session, ref, false))
break;
/*
@@ -503,7 +504,7 @@ restart: /*
/*
* Try to skip deleted pages visible to us.
*/
- if (ref->state == WT_REF_DELETED &&
+ if (current_state == WT_REF_DELETED &&
__wt_delete_page_skip(session, ref, false))
break;
}
diff --git a/src/third_party/wiredtiger/src/config/config_def.c b/src/third_party/wiredtiger/src/config/config_def.c
index a70b8f86648..cc3ea7c9d52 100644
--- a/src/third_party/wiredtiger/src/config/config_def.c
+++ b/src/third_party/wiredtiger/src/config/config_def.c
@@ -217,7 +217,8 @@ static const WT_CONFIG_CHECK confchk_WT_CURSOR_reconfigure[] = {
static const WT_CONFIG_CHECK confchk_assert_subconfigs[] = {
{ "commit_timestamp", "string",
- NULL, "choices=[\"always\",\"never\",\"none\"]",
+ NULL, "choices=[\"always\",\"key_consistent\",\"never\","
+ "\"none\"]",
NULL, 0 },
{ "read_timestamp", "string",
NULL, "choices=[\"always\",\"never\",\"none\"]",
diff --git a/src/third_party/wiredtiger/src/docs/transactions.dox b/src/third_party/wiredtiger/src/docs/transactions.dox
index f66923aac3f..d27e796b8e9 100644
--- a/src/third_party/wiredtiger/src/docs/transactions.dox
+++ b/src/third_party/wiredtiger/src/docs/transactions.dox
@@ -201,8 +201,7 @@ been used. This is enforced by assertions in diagnostic builds, if
applications violate this rule, data consistency can be violated.
The commits to a particular data item must be performed in timestamp order.
-Again, this is only checked in diagnostic builds and if applications violate
-this rule, data consistency can be violated.
+If applications violate this rule, data consistency can be violated.
@subsection Timestamp support in the extension API
diff --git a/src/third_party/wiredtiger/src/include/btree.h b/src/third_party/wiredtiger/src/include/btree.h
index e3fd6d5e66d..96f6309aba4 100644
--- a/src/third_party/wiredtiger/src/include/btree.h
+++ b/src/third_party/wiredtiger/src/include/btree.h
@@ -98,10 +98,11 @@ struct __wt_btree {
uint64_t splitmempage; /* In-memory split trigger size */
/* AUTOMATIC FLAG VALUE GENERATION START */
-#define WT_ASSERT_COMMIT_TS_ALWAYS 0x1u
-#define WT_ASSERT_COMMIT_TS_NEVER 0x2u
-#define WT_ASSERT_READ_TS_ALWAYS 0x4u
-#define WT_ASSERT_READ_TS_NEVER 0x8u
+#define WT_ASSERT_COMMIT_TS_ALWAYS 0x01u
+#define WT_ASSERT_COMMIT_TS_KEYS 0x02u
+#define WT_ASSERT_COMMIT_TS_NEVER 0x04u
+#define WT_ASSERT_READ_TS_ALWAYS 0x08u
+#define WT_ASSERT_READ_TS_NEVER 0x10u
/* AUTOMATIC FLAG VALUE GENERATION STOP */
uint32_t assert_flags; /* Debugging assertion information */
diff --git a/src/third_party/wiredtiger/src/include/optrack.h b/src/third_party/wiredtiger/src/include/optrack.h
index bec724042cf..8593a20d2c4 100644
--- a/src/third_party/wiredtiger/src/include/optrack.h
+++ b/src/third_party/wiredtiger/src/include/optrack.h
@@ -8,7 +8,7 @@
#define WT_OPTRACK_MAXRECS (16384)
#define WT_OPTRACK_BUFSIZE (WT_OPTRACK_MAXRECS * sizeof(WT_OPTRACK_RECORD))
-#define WT_OPTRACK_VERSION 1
+#define WT_OPTRACK_VERSION 2
/*
* WT_OPTRACK_HEADER --
@@ -18,6 +18,7 @@
struct __wt_optrack_header {
uint32_t optrack_version;
uint32_t optrack_session_internal;
+ uint32_t optrack_tsc_nsec_ratio;
};
/*
diff --git a/src/third_party/wiredtiger/src/include/txn.h b/src/third_party/wiredtiger/src/include/txn.h
index a0f51be8a28..3f48368b303 100644
--- a/src/third_party/wiredtiger/src/include/txn.h
+++ b/src/third_party/wiredtiger/src/include/txn.h
@@ -275,8 +275,9 @@ struct __wt_txn {
#define WT_TXN_RUNNING 0x0400u
#define WT_TXN_SYNC_SET 0x0800u
#define WT_TXN_TS_COMMIT_ALWAYS 0x1000u
-#define WT_TXN_TS_COMMIT_NEVER 0x2000u
-#define WT_TXN_UPDATE 0x4000u
+#define WT_TXN_TS_COMMIT_KEYS 0x2000u
+#define WT_TXN_TS_COMMIT_NEVER 0x4000u
+#define WT_TXN_UPDATE 0x8000u
/* AUTOMATIC FLAG VALUE GENERATION STOP */
uint32_t flags;
};
diff --git a/src/third_party/wiredtiger/src/include/txn.i b/src/third_party/wiredtiger/src/include/txn.i
index 121a18c9c3c..fbd89195746 100644
--- a/src/third_party/wiredtiger/src/include/txn.i
+++ b/src/third_party/wiredtiger/src/include/txn.i
@@ -26,6 +26,8 @@ __wt_txn_timestamp_flags(WT_SESSION_IMPL *session)
return;
if (FLD_ISSET(btree->assert_flags, WT_ASSERT_COMMIT_TS_ALWAYS))
F_SET(&session->txn, WT_TXN_TS_COMMIT_ALWAYS);
+ if (FLD_ISSET(btree->assert_flags, WT_ASSERT_COMMIT_TS_KEYS))
+ F_SET(&session->txn, WT_TXN_TS_COMMIT_KEYS);
if (FLD_ISSET(btree->assert_flags, WT_ASSERT_COMMIT_TS_NEVER))
F_SET(&session->txn, WT_TXN_TS_COMMIT_NEVER);
}
diff --git a/src/third_party/wiredtiger/src/optrack/optrack.c b/src/third_party/wiredtiger/src/optrack/optrack.c
index 4ac56391f15..8258a715927 100644
--- a/src/third_party/wiredtiger/src/optrack/optrack.c
+++ b/src/third_party/wiredtiger/src/optrack/optrack.c
@@ -54,7 +54,8 @@ __wt_optrack_open_file(WT_SESSION_IMPL *session)
WT_CONNECTION_IMPL *conn;
WT_DECL_ITEM(buf);
WT_DECL_RET;
- WT_OPTRACK_HEADER optrack_header = {WT_OPTRACK_VERSION, 0};
+ WT_OPTRACK_HEADER optrack_header = { WT_OPTRACK_VERSION, 0,
+ (uint32_t)WT_TSC_DEFAULT_RATIO * WT_THOUSAND };
conn = S2C(session);
@@ -68,10 +69,18 @@ __wt_optrack_open_file(WT_SESSION_IMPL *session)
(const char *)buf->data, WT_FS_OPEN_FILE_TYPE_REGULAR,
WT_FS_OPEN_CREATE, &session->optrack_fh));
- /* Write the header into the operation-tracking file. */
+ /* Indicate whether this is an internal session */
if (F_ISSET(session, WT_SESSION_INTERNAL))
optrack_header.optrack_session_internal = 1;
+ /*
+ * Record the clock ticks to nanoseconds ratio. Multiply it by one
+ * thousand, so we can use a fixed width integer.
+ */
+ optrack_header.optrack_tsc_nsec_ratio =
+ (uint32_t)(__wt_process.tsc_nsec_ratio * WT_THOUSAND);
+
+ /* Write the header into the operation-tracking file. */
WT_ERR(session->optrack_fh->handle->fh_write(
session->optrack_fh->handle, (WT_SESSION *)session,
0, sizeof(WT_OPTRACK_HEADER), &optrack_header));
diff --git a/src/third_party/wiredtiger/src/support/hazard.c b/src/third_party/wiredtiger/src/support/hazard.c
index 42148b068fb..815c876f444 100644
--- a/src/third_party/wiredtiger/src/support/hazard.c
+++ b/src/third_party/wiredtiger/src/support/hazard.c
@@ -72,6 +72,7 @@ __wt_hazard_set(WT_SESSION_IMPL *session, WT_REF *ref, bool *busyp
)
{
WT_HAZARD *hp;
+ uint32_t current_state;
*busyp = false;
@@ -84,7 +85,8 @@ __wt_hazard_set(WT_SESSION_IMPL *session, WT_REF *ref, bool *busyp
* eviction and splits, we re-check it after a barrier to make sure
* we have a valid reference.
*/
- if (ref->state != WT_REF_LIMBO && ref->state != WT_REF_MEM) {
+ current_state = ref->state;
+ if (current_state != WT_REF_LIMBO && current_state != WT_REF_MEM) {
*busyp = true;
return (0);
}
@@ -154,7 +156,8 @@ __wt_hazard_set(WT_SESSION_IMPL *session, WT_REF *ref, bool *busyp
* Check if the page state is still valid, where valid means a
* state of WT_REF_LIMBO or WT_REF_MEM.
*/
- if (ref->state == WT_REF_LIMBO || ref->state == WT_REF_MEM) {
+ current_state = ref->state;
+ if (current_state == WT_REF_LIMBO || current_state == WT_REF_MEM) {
++session->nhazard;
/*
diff --git a/src/third_party/wiredtiger/src/txn/txn.c b/src/third_party/wiredtiger/src/txn/txn.c
index 6d1321b1a13..5d70acb90f0 100644
--- a/src/third_party/wiredtiger/src/txn/txn.c
+++ b/src/third_party/wiredtiger/src/txn/txn.c
@@ -612,7 +612,7 @@ __txn_commit_timestamp_validate(WT_SESSION_IMPL *session)
WT_TXN_OP *op;
WT_UPDATE *upd;
u_int i;
- char timestamp_buf[2][2 * WT_TIMESTAMP_SIZE + 1];
+ bool op_used_ts, upd_used_ts;
txn = &session->txn;
@@ -630,39 +630,50 @@ __txn_commit_timestamp_validate(WT_SESSION_IMPL *session)
WT_RET_MSG(session, EINVAL, "no commit_timestamp required and "
"timestamp set on this transaction");
- if (WT_VERBOSE_ISSET(session, WT_VERB_TIMESTAMP)) {
- /*
- * Error on any valid update structures for the same key that
- * are at a later timestamp.
- */
- for (i = 0, op = txn->mod; i < txn->mod_count; i++, op++) {
- if (op->type != WT_TXN_OP_BASIC_TS)
- continue;
+ /*
+ * If we're not doing any key consistency checking, we're done.
+ */
+ if (!F_ISSET(txn, WT_TXN_TS_COMMIT_KEYS))
+ return (0);
+
+ /*
+ * Error on any valid update structures for the same key that
+ * are at a later timestamp or use timestamps inconsistently.
+ */
+ for (i = 0, op = txn->mod; i < txn->mod_count; i++, op++)
+ if (op->type == WT_TXN_OP_BASIC_TS ||
+ op->type == WT_TXN_OP_BASIC) {
/*
* Skip over any aborted update structures.
*/
upd = op->u.upd->next;
while (upd != NULL && upd->txnid == WT_TXN_ABORTED)
upd = upd->next;
+
/*
* Check the timestamp on this update with the
* first valid update in the chain. They're in
* most recent order.
*/
- if (upd != NULL &&
- __wt_timestamp_cmp(&op->u.upd->timestamp,
- &upd->timestamp) < 0) {
- WT_RET(__wt_timestamp_to_hex_string(session,
- timestamp_buf[0], &op->u.upd->timestamp));
- WT_RET(__wt_timestamp_to_hex_string(session,
- timestamp_buf[1], &upd->timestamp));
- __wt_verbose(session, WT_VERB_TIMESTAMP,
- "Timestamp %s on new update is older than "
- "timestamp %s on existing update.",
- timestamp_buf[0], timestamp_buf[1]);
- }
+ if (upd == NULL)
+ continue;
+ /*
+ * Check for consistent per-key timestamp usage.
+ * If timestamps are or are not used originally then
+ * they should be used the same way always. Check
+ * timestamps are used in order.
+ */
+ op_used_ts =
+ __wt_timestamp_iszero(&op->u.upd->timestamp);
+ upd_used_ts = __wt_timestamp_iszero(&upd->timestamp);
+ if (op_used_ts != upd_used_ts)
+ WT_RET_MSG(session, EINVAL,
+ "per-key timestamps used inconsistently");
+ if (__wt_timestamp_cmp(&op->u.upd->timestamp,
+ &upd->timestamp) < 0)
+ WT_RET_MSG(session, EINVAL,
+ "out of order timestamps");
}
- }
return (0);
}
#endif
diff --git a/src/third_party/wiredtiger/src/txn/txn_log.c b/src/third_party/wiredtiger/src/txn/txn_log.c
index a52e97d6b44..d31a9e27583 100644
--- a/src/third_party/wiredtiger/src/txn/txn_log.c
+++ b/src/third_party/wiredtiger/src/txn/txn_log.c
@@ -25,6 +25,7 @@ __txn_op_log_row_key_check(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
WT_ITEM key;
WT_PAGE *page;
WT_ROW *rip;
+ int cmp;
cursor = &cbt->iface;
WT_ASSERT(session, F_ISSET(cursor, WT_CURSTD_KEY_SET));
@@ -50,8 +51,9 @@ __txn_op_log_row_key_check(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
key.size = WT_INSERT_KEY_SIZE(cbt->ins);
}
- WT_ASSERT(session, key.size == cursor->key.size &&
- memcmp(key.data, cursor->key.data, key.size) == 0);
+ WT_ASSERT(session, __wt_compare(
+ session, cbt->btree->collator, &key, &cursor->key, &cmp) == 0);
+ WT_ASSERT(session, cmp == 0);
__wt_buf_free(session, &key);
}