summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2013-03-22 17:56:00 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2013-03-22 17:56:00 +1100
commitb62b2b3842c33ccfeb6645342120b8ed901b8e6c (patch)
tree46a0077be03c2b54ba4001aad869a91161e51b23
parentc46d075b7f6f6c6f6fbf7bedb11e66c96766267c (diff)
downloadmongo-b62b2b3842c33ccfeb6645342120b8ed901b8e6c.tar.gz
Take more care not to use a stale value for the oldest reader transaction ID.
-rw-r--r--src/include/txn.h4
-rw-r--r--src/txn/txn.c10
2 files changed, 8 insertions, 6 deletions
diff --git a/src/include/txn.h b/src/include/txn.h
index ba0a397699f..e87df4bae5d 100644
--- a/src/include/txn.h
+++ b/src/include/txn.h
@@ -80,8 +80,8 @@ struct __wt_txn {
*/
wt_txnid_t oldest_snap_min;
- /* Saved global state, to avoid scans. */
- wt_txnid_t last_id;
+ /* Saved global state, to avoid repeating scans. */
+ wt_txnid_t last_id, last_oldest_id;
uint32_t last_gen, last_oldest_gen;
/*
diff --git a/src/txn/txn.c b/src/txn/txn.c
index ae88a19a478..6e2ba2d5e33 100644
--- a/src/txn/txn.c
+++ b/src/txn/txn.c
@@ -76,13 +76,15 @@ __wt_txn_get_oldest(WT_SESSION_IMPL *session)
txn = &session->txn;
txn_global = &conn->txn_global;
+ oldest_snap_min =
+ (txn->id != WT_TXN_NONE) ? txn->id : txn_global->current;
+
/* If nothing has changed since last time, we're done. */
- if (txn->last_oldest_gen == txn_global->gen)
+ if (txn->last_oldest_gen == txn_global->gen &&
+ txn->last_oldest_id == oldest_snap_min)
return;
txn->last_oldest_gen = txn_global->gen;
-
- oldest_snap_min =
- (txn->id != WT_TXN_NONE) ? txn->id : txn_global->current;
+ txn->last_oldest_id = oldest_snap_min;
WT_ORDERED_READ(session_cnt, conn->session_cnt);
for (i = 0, s = txn_global->states;