diff options
author | Luke Chen <luke.chen@mongodb.com> | 2018-02-08 17:31:44 +1100 |
---|---|---|
committer | Luke Chen <luke.chen@mongodb.com> | 2018-02-08 17:31:44 +1100 |
commit | 7574817caec09fa1a2ab5ea60f00f766da63f9cd (patch) | |
tree | 6663806102c99c609c86b856409d6496179e4195 /src/third_party/wiredtiger/src/txn/txn.c | |
parent | 34d2da2cfb93244818ecb55843f58d359151198d (diff) | |
download | mongo-7574817caec09fa1a2ab5ea60f00f766da63f9cd.tar.gz |
Import wiredtiger: a6e72378a60249228730667a2cba9a90c454b786 from branch mongodb-3.8
ref: 06a940e28a..a6e72378a6
for: 3.7.2
WT-3766 Lookaside sweep for obsolete updates
WT-3840 Dump more information when data corruption is encountered
WT-3847 Add a stub API for prepared transaction
WT-3854 Remove write lock from commit path, leaving old entries in queue
WT-3866 Bi-weekly WT codebase lint
WT-3877 WT_CONN_EVICTION_NO_LOOKASIDE is cleared unconditionally
WT-3878 Iteration can lose its position when updating a limbo page
WT-3881 key timestamp consistency checking should not check its own updates
WT-3887 log operations in format snapshot-isolation tracking
WT-3888 cursor search-near can return the wrong value for "exact"
WT-3889 format key-order return failure in LSM
WT-3890 core dump walking timestamp queue
WT-3891 Take the sweep walk rwlock whenever removing content from lookaside
WT-3895 Commit timestamp queue getting out of order
Diffstat (limited to 'src/third_party/wiredtiger/src/txn/txn.c')
-rw-r--r-- | src/third_party/wiredtiger/src/txn/txn.c | 62 |
1 files changed, 52 insertions, 10 deletions
diff --git a/src/third_party/wiredtiger/src/txn/txn.c b/src/third_party/wiredtiger/src/txn/txn.c index 5d70acb90f0..627bafa7483 100644 --- a/src/third_party/wiredtiger/src/txn/txn.c +++ b/src/third_party/wiredtiger/src/txn/txn.c @@ -449,6 +449,14 @@ __wt_txn_config(WT_SESSION_IMPL *session, const char *cfg[]) WT_RET(__wt_txn_parse_timestamp(session, "read", &ts, &cval)); /* + * Prepare transactions are supported only in timestamp build. + */ + WT_RET(__wt_config_gets_def(session, + cfg, "ignore_prepare", 0, &cval)); + if (cval.val) + F_SET(txn, WT_TXN_IGNORE_PREPARE); + + /* * Read the configuration here to reduce the span of the * critical section. */ @@ -608,11 +616,12 @@ __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; u_int i; - bool op_used_ts, upd_used_ts; + bool op_zero_ts, upd_zero_ts; txn = &session->txn; @@ -644,10 +653,12 @@ __txn_commit_timestamp_validate(WT_SESSION_IMPL *session) if (op->type == WT_TXN_OP_BASIC_TS || op->type == WT_TXN_OP_BASIC) { /* - * Skip over any aborted update structures. + * Skip over any aborted update structures or ones + * from our own transaction. */ upd = op->u.upd->next; - while (upd != NULL && upd->txnid == WT_TXN_ABORTED) + while (upd != NULL && (upd->txnid == WT_TXN_ABORTED || + upd->txnid == txn->id)) upd = upd->next; /* @@ -660,16 +671,31 @@ __txn_commit_timestamp_validate(WT_SESSION_IMPL *session) /* * 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. + * they should be used the same way always. For this + * transaction, timestamps are in use anytime the + * commit timestamp is set. + * 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) + op_zero_ts = !F_ISSET(txn, WT_TXN_HAS_TS_COMMIT); + upd_zero_ts = __wt_timestamp_iszero(&upd->timestamp); + if (op_zero_ts != upd_zero_ts) WT_RET_MSG(session, EINVAL, "per-key timestamps used inconsistently"); - if (__wt_timestamp_cmp(&op->u.upd->timestamp, + /* + * If we aren't using timestamps for this transaction + * then we are done checking. Don't check the timestamp + * because the one in the transaction is not cleared. + */ + if (op_zero_ts) + continue; + op_timestamp = op->u.upd->timestamp; + /* + * Only if the update structure doesn't have a timestamp + * then use the one in the transaction structure. + */ + if (__wt_timestamp_iszero(&op->u.upd->timestamp)) + op_timestamp = txn->commit_timestamp; + if (__wt_timestamp_cmp(&op_timestamp, &upd->timestamp) < 0) WT_RET_MSG(session, EINVAL, "out of order timestamps"); @@ -941,6 +967,22 @@ err: /* } /* + * __wt_txn_prepare -- + * Prepare the current transaction. + */ +int +__wt_txn_prepare(WT_SESSION_IMPL *session, const char *cfg[]) +{ + WT_UNUSED(cfg); + +#ifdef HAVE_TIMESTAMPS + WT_RET_MSG(session, ENOTSUP, "prepare_transaction is not supported"); +#else + WT_RET_MSG(session, ENOTSUP, "prepare_transaction requires a version " + "of WiredTiger built with timestamp support"); +#endif +} +/* * __wt_txn_rollback -- * Roll back the current transaction. */ |