From 5432949c4f9bf536b3932d7cc9b0186461316009 Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Tue, 14 May 2013 11:12:15 +1000 Subject: Fix an off-by-one error in the transaction used for eviction. We track the oldest ID that can *not* be written. --- src/btree/bt_evict.c | 8 ++++++++ src/txn/txn.c | 11 +++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/btree/bt_evict.c b/src/btree/bt_evict.c index 3bbc31e1582..a81c65a1ecd 100644 --- a/src/btree/bt_evict.c +++ b/src/btree/bt_evict.c @@ -333,6 +333,14 @@ __wt_evict_page(WT_SESSION_IMPL *session, WT_PAGE *page) __wt_txn_get_evict_snapshot(session); txn->isolation = TXN_ISO_READ_COMMITTED; + + /* + * Sanity check: if a transaction is running, its updates should not + * be visible to eviction. + */ + WT_ASSERT(session, !was_running || + !__wt_txn_visible(session, saved_txn.id)); + ret = __wt_rec_evict(session, page, 0); if (was_running) { diff --git a/src/txn/txn.c b/src/txn/txn.c index c1a72ecd671..587983bc14e 100644 --- a/src/txn/txn.c +++ b/src/txn/txn.c @@ -168,9 +168,14 @@ __wt_txn_get_evict_snapshot(WT_SESSION_IMPL *session) txn = &session->txn; + /* + * The oldest active snapshot ID in the system should *not* be visible + * to eviction. Create a snapshot containing that ID. + */ __wt_txn_get_oldest(session); + txn->snapshot[0] = txn->oldest_snap_min; __txn_sort_snapshot( - session, 0, txn->oldest_snap_min, txn->oldest_snap_min); + session, 1, txn->oldest_snap_min, txn->oldest_snap_min); /* * Note that we carefully don't update the global table with this @@ -397,9 +402,7 @@ __wt_txn_init(WT_SESSION_IMPL *session) txn->mod = NULL; txn->modref = NULL; - /* The default isolation level is read-committed. */ - txn->isolation = session->isolation = TXN_ISO_READ_COMMITTED; - + txn->isolation = session->isolation; return (0); } -- cgit v1.2.1