diff options
author | Luke Chen <luke.chen@mongodb.com> | 2021-06-10 16:47:49 +1000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-10 07:24:58 +0000 |
commit | 2ac8bccf9d91e538f1ea17d04d6a5abe4d095e63 (patch) | |
tree | 1834f705dfc5ad178c8a374421da56511ff51fec /src/third_party | |
parent | 2b6ed3f30dcfd83d0b7a6f6f29eb321fd3e81b11 (diff) | |
download | mongo-2ac8bccf9d91e538f1ea17d04d6a5abe4d095e63.tar.gz |
Import wiredtiger: 5904d74bfd3de3da526e0af3367f391a44e4c0e6 from branch mongodb-5.0
ref: 8ab25823a1..5904d74bfd
for: 5.0.0-rc2
WT-7585 Fix cyclomatic-complexity test failure
Diffstat (limited to 'src/third_party')
-rw-r--r-- | src/third_party/wiredtiger/import.data | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/reconcile/rec_visibility.c | 89 |
2 files changed, 53 insertions, 38 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index bc2aed03a27..957e85b2417 100644 --- a/src/third_party/wiredtiger/import.data +++ b/src/third_party/wiredtiger/import.data @@ -2,5 +2,5 @@ "vendor": "wiredtiger", "github": "wiredtiger/wiredtiger.git", "branch": "mongodb-5.0", - "commit": "8ab25823a1608357983965f1729bf5fbf0ba217d" + "commit": "5904d74bfd3de3da526e0af3367f391a44e4c0e6" } diff --git a/src/third_party/wiredtiger/src/reconcile/rec_visibility.c b/src/third_party/wiredtiger/src/reconcile/rec_visibility.c index ef5c3246e30..0e5523b6454 100644 --- a/src/third_party/wiredtiger/src/reconcile/rec_visibility.c +++ b/src/third_party/wiredtiger/src/reconcile/rec_visibility.c @@ -223,6 +223,56 @@ __rec_need_save_upd( } /* + * __get_valid_upd -- + * Loop until a valid update from a different transaction is found in the update list. As a side + * effect method saves the latest update from the same transaction into the WT_UPDATE output + * argument. Method returns a valid update from a different transaction. + */ +static inline WT_UPDATE * +__get_valid_upd(WT_UPDATE *upd, WT_UPDATE *tombstone, WT_UPDATE **same_txn_valid_upd) +{ + while (upd->next != NULL) { + if (upd->next->txnid == WT_TXN_ABORTED) + upd = upd->next; + else if (upd->next->txnid != WT_TXN_NONE && tombstone->txnid == upd->next->txnid) { + upd = upd->next; + /* Save the latest update from the same transaction. */ + if (*same_txn_valid_upd == NULL) + *same_txn_valid_upd = upd; + } else + break; + } + + return upd; +} + +/* + * __timestamp_out_of_order_fix -- + * If we found a tombstone with a time point earlier than the update it applies to, which can + * happen if the application performs operations with timestamps out-of-order, make it invisible + * by making the start time point match the stop time point of the tombstone. We don't guarantee + * that older readers will be able to continue reading content that has been made invisible by + * out-of-order updates. Note that we carefully don't take this path when the stop time point is + * equal to the start time point. While unusual, it is permitted for a single transaction to + * insert and then remove a record. We don't want to generate a warning in that case. + */ +static inline void +__timestamp_out_of_order_fix(WT_SESSION_IMPL *session, WT_TIME_WINDOW *select_tw) +{ + char time_string[WT_TIME_STRING_SIZE]; + + if (select_tw->stop_ts < select_tw->start_ts || + (select_tw->stop_ts == select_tw->start_ts && select_tw->stop_txn < select_tw->start_txn)) { + __wt_verbose(session, WT_VERB_TIMESTAMP, + "Warning: fixing out-of-order timestamps remove earlier than value; time window %s", + __wt_time_window_to_string(select_tw, time_string)); + + select_tw->durable_start_ts = select_tw->durable_stop_ts; + select_tw->start_ts = select_tw->stop_ts; + } +} + +/* * __wt_rec_upd_select -- * Return the update in a list that should be written (or NULL if none can be written). */ @@ -238,7 +288,6 @@ __wt_rec_upd_select(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins, v wt_timestamp_t max_ts; size_t upd_memsize; uint64_t max_txn, session_txnid, txnid; - char time_string[WT_TIME_STRING_SIZE]; bool has_newer_updates, is_hs_page, supd_restore, upd_saved; /* @@ -439,22 +488,7 @@ __wt_rec_upd_select(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins, v /* Find the update this tombstone applies to. */ if (!__wt_txn_upd_visible_all(session, upd)) { - /* - * Loop until a valid update from a different transaction is found in the update - * list. - */ - while (upd->next != NULL) { - if (upd->next->txnid == WT_TXN_ABORTED) - upd = upd->next; - else if (upd->next->txnid != WT_TXN_NONE && - tombstone->txnid == upd->next->txnid) { - upd = upd->next; - /* Save the latest update from the same transaction. */ - if (same_txn_valid_upd == NULL) - same_txn_valid_upd = upd; - } else - break; - } + upd = __get_valid_upd(upd, tombstone, &same_txn_valid_upd); WT_ASSERT(session, upd->next == NULL || upd->next->txnid != WT_TXN_ABORTED); upd_select->upd = upd = upd->next; @@ -562,26 +596,7 @@ __wt_rec_upd_select(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins, v } } - /* - * If we found a tombstone with a time point earlier than the update it applies to, which can - * happen if the application performs operations with timestamps out-of-order, make it invisible - * by making the start time point match the stop time point of the tombstone. We don't guarantee - * that older readers will be able to continue reading content that has been made invisible by - * out-of-order updates. - * - * Note that we carefully don't take this path when the stop time point is equal to the start - * time point. While unusual, it is permitted for a single transaction to insert and then remove - * a record. We don't want to generate a warning in that case. - */ - if (select_tw->stop_ts < select_tw->start_ts || - (select_tw->stop_ts == select_tw->start_ts && select_tw->stop_txn < select_tw->start_txn)) { - __wt_verbose(session, WT_VERB_TIMESTAMP, - "Warning: fixing out-of-order timestamps remove earlier than value; time window %s", - __wt_time_window_to_string(select_tw, time_string)); - - select_tw->durable_start_ts = select_tw->durable_stop_ts; - select_tw->start_ts = select_tw->stop_ts; - } + __timestamp_out_of_order_fix(session, select_tw); /* * Track the most recent transaction in the page. We store this in the tree at the end of |