summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/include/txn.i
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/include/txn.i')
-rw-r--r--src/third_party/wiredtiger/src/include/txn.i237
1 files changed, 23 insertions, 214 deletions
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);
}