summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/cache/cache_las.c
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2018-03-12 16:17:14 +1100
committerLuke Chen <luke.chen@mongodb.com>2018-03-12 16:17:14 +1100
commite2c455353d8d96eb8abe3ffa6bf482bef0e4229e (patch)
tree1397f9767f06c244f108a575d2f838496121976c /src/third_party/wiredtiger/src/cache/cache_las.c
parent7fb9fa1533e40e71238a51c02fcb7b77d0402663 (diff)
downloadmongo-e2c455353d8d96eb8abe3ffa6bf482bef0e4229e.tar.gz
Import wiredtiger: 4d5794b93795d52af97dc150d81b637442b89c5d from branch mongodb-3.6
ref: bc82f0f038..4d5794b937 for: 3.6.4 WT-1228 Improve performance of WT_SESSION::open_cursor WT-3805 Avoid reading lookaside pages in truncate fast path WT-3815 Cursor caching: measure and tune performance WT-3829 WiredTiger metadata can be logically inconsistent. WT-3848 Enhance new prepare transaction API to enforce post conditions WT-3850 Implement WT_SESSSION::prepare_transaction WT-3868 Bi-weekly WT codebase lint WT-3901 Corruption of operation tracking log files WT-3904 Reconsider error path in log server thread WT-3905 Save the timestamp used for a checkpoint WT-3906 Respect stable_timestamp in WT_CONNECTION::close WT-3911 Ignore lookaside data on shutdown WT-3912 fast-delete pages should re-instantiate the delete transaction's timestamp. WT-3923 __wt_txn_context_prepare_check() requires API initialization WT-3925 Fix test format operation selection code WT-3926 Allow read_timestamp to be set after begin_transaction WT-3927 Disable truncate testing with LSM WT-3930 Set the recovery timestamp even if recovery doesn't run WT-3932 WiredTiger memory allocation failure in js_test WT-3933 test/format failure illegal WT_REF.state rolling back deleted page WT-3934 LSM chunk checkpoints can race with system checkpoints WT-3935 Enable cursor caching by default in WiredTiger. WT-3936 Add multi-threaded tests for prepare_transaction() WT-3938 Reduce memory usage with many tables and sessions WT-3939 test_txn14.test_txn14.test_log_flush timeout WT-3940 s_export issue detected during WiredTiger release execution WT-3942 Update test_compact02 to handle being halted by eviction pressure. WT-3945 Support libwiredtiger.so checking in s_export WT-3946 Truncate segfault with a NULL start cursor WT-3947 Allow wiredtiger_open configuration to disable cursor caching WT-3948 Data handle loop may terminate without applying operations WT-3949 Buffer overflow in WT_CURSOR::modify for string values WT-3952 page-delete update list traversed after it has been discarded. WT-3953 test/format can attempt to set an illegal prepare timestamp WT-3954 test/format: prepared operations evicted before commit WT-3961 The all_committed timestamp should be less than any in-flight transaction WT-3964 Stop wrapping schema operations in a transaction WT-3967 Fix long test for cursor cache sweep
Diffstat (limited to 'src/third_party/wiredtiger/src/cache/cache_las.c')
-rw-r--r--src/third_party/wiredtiger/src/cache/cache_las.c98
1 files changed, 97 insertions, 1 deletions
diff --git a/src/third_party/wiredtiger/src/cache/cache_las.c b/src/third_party/wiredtiger/src/cache/cache_las.c
index 1f0b9c4b285..569a0247e7b 100644
--- a/src/third_party/wiredtiger/src/cache/cache_las.c
+++ b/src/third_party/wiredtiger/src/cache/cache_las.c
@@ -354,6 +354,102 @@ __wt_las_cursor_close(
}
/*
+ * __wt_las_page_skip_locked --
+ * Check if we can skip reading a page with lookaside entries, where
+ * the page is already locked.
+ */
+bool
+__wt_las_page_skip_locked(WT_SESSION_IMPL *session, WT_REF *ref)
+{
+ WT_TXN *txn;
+
+ txn = &session->txn;
+
+ /*
+ * Skip lookaside pages if reading without a timestamp and all the
+ * updates in lookaside are in the past.
+ *
+ * Lookaside eviction preferentially chooses the newest updates when
+ * creating page images with no stable timestamp. If a stable timestamp
+ * has been set, we have to visit the page because eviction chooses old
+ * version of records in that case.
+ *
+ * One case where we may need to visit the page is if lookaside eviction
+ * is active in tree 2 when a checkpoint has started and is working its
+ * way through tree 1. In that case, lookaside may have created a page
+ * image with updates in the future of the checkpoint.
+ *
+ * We also need to instantiate a lookaside page if this is an update
+ * operation in progress.
+ */
+ if (ref->page_las->invalid)
+ return (false);
+
+ if (F_ISSET(txn, WT_TXN_UPDATE))
+ return (false);
+
+ if (!F_ISSET(txn, WT_TXN_HAS_SNAPSHOT))
+ return (false);
+
+ if (WT_TXNID_LE(txn->snap_min, ref->page_las->las_max_txn))
+ return (false);
+
+ if (!F_ISSET(txn, WT_TXN_HAS_TS_READ) && ref->page_las->las_skew_newest)
+ return (true);
+
+#ifdef HAVE_TIMESTAMPS
+ /*
+ * Skip lookaside pages if reading as of a timestamp, we evicted new
+ * versions of data and all the updates are in the past.
+ */
+ if (F_ISSET(&session->txn, WT_TXN_HAS_TS_READ) &&
+ ref->page_las->las_skew_newest &&
+ __wt_timestamp_cmp(
+ &ref->page_las->onpage_timestamp, &session->txn.read_timestamp) < 0)
+ return (true);
+
+ /*
+ * Skip lookaside pages if reading as of a timestamp, we evicted old
+ * versions of data and all the updates are in the future.
+ */
+ if (F_ISSET(&session->txn, WT_TXN_HAS_TS_READ) &&
+ !ref->page_las->las_skew_newest &&
+ __wt_timestamp_cmp(
+ &ref->page_las->min_timestamp, &session->txn.read_timestamp) > 0)
+ return (true);
+#endif
+
+ return (false);
+}
+
+/*
+ * __wt_las_page_skip --
+ * Check if we can skip reading a page with lookaside entries, where the
+ * page needs to be locked before checking.
+ */
+bool
+__wt_las_page_skip(WT_SESSION_IMPL *session, WT_REF *ref)
+{
+ uint32_t previous_state;
+ bool skip;
+
+ if ((previous_state = ref->state) != WT_REF_LIMBO &&
+ previous_state != WT_REF_LOOKASIDE)
+ return (false);
+
+ if (!__wt_atomic_casv32(&ref->state, previous_state, WT_REF_LOCKED))
+ return (false);
+
+ skip = __wt_las_page_skip_locked(session, ref);
+
+ /* Restore the state and push the change. */
+ ref->state = previous_state;
+ WT_FULL_BARRIER();
+
+ return (skip);
+}
+
+/*
* __las_remove_block --
* Remove all records for a given page from the lookaside store.
*/
@@ -709,7 +805,7 @@ __wt_las_cursor_position(WT_CURSOR *cursor, uint32_t btree_id, uint64_t pageid)
* Because of the special visibility rules for
* lookaside, a new block can appear in between our
* search and the block of interest. Keep trying while
- * we have a key lower that we expect.
+ * we have a key lower than we expect.
*
* There may be no block of lookaside entries if they
* have been removed by