From 2fdb9c36748c3206914a3c6ca23720ce7cc75317 Mon Sep 17 00:00:00 2001 From: Chenhao Qu Date: Wed, 5 Aug 2020 12:32:32 +0000 Subject: Import wiredtiger: 54d5655b43b91028ee1c90eadd0969c863a9e7e5 from branch mongodb-4.6 ref: 91b5d984b9..54d5655b43 for: 4.5.1 WT-6491 No need to append the onpage value if it is prepared --- src/third_party/wiredtiger/import.data | 2 +- .../wiredtiger/src/reconcile/rec_visibility.c | 47 +++++++--------------- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index 62f713290ac..c1416ad69ba 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-4.6", - "commit": "91b5d984b963379e2a9bb0cf0b048d3720202a1c" + "commit": "54d5655b43b91028ee1c90eadd0969c863a9e7e5" } diff --git a/src/third_party/wiredtiger/src/reconcile/rec_visibility.c b/src/third_party/wiredtiger/src/reconcile/rec_visibility.c index f001d787997..523ed514415 100644 --- a/src/third_party/wiredtiger/src/reconcile/rec_visibility.c +++ b/src/third_party/wiredtiger/src/reconcile/rec_visibility.c @@ -50,8 +50,8 @@ __rec_update_save(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins, voi /* * __rec_append_orig_value -- * Append the key's original value to its update list. It assumes that we have an onpage value, - * and we don't overwrite transaction id to WT_TXN_NONE and timestamps to WT_TS_NONE in time - * window for in-memory databases. + * the onpage value is not a prepared update, and we don't overwrite transaction id to + * WT_TXN_NONE and timestamps to WT_TS_NONE in time window for in-memory databases. */ static int __rec_append_orig_value( @@ -63,7 +63,8 @@ __rec_append_orig_value( size_t size, total_size; bool tombstone_globally_visible; - WT_ASSERT(session, upd != NULL && unpack != NULL && unpack->type != WT_CELL_DEL); + WT_ASSERT( + session, upd != NULL && unpack != NULL && unpack->type != WT_CELL_DEL && !unpack->tw.prepare); append = oldest_upd = tombstone = NULL; total_size = 0; @@ -75,13 +76,6 @@ __rec_append_orig_value( if (F_ISSET(upd, WT_UPDATE_RESTORED_FROM_DS | WT_UPDATE_RESTORED_FROM_HS)) return (0); - /* - * Prepared updates should already be in the update list, add the original update to the - * list only when the prepared update is a tombstone. - */ - if (unpack->tw.prepare && upd->type != WT_UPDATE_TOMBSTONE) - return (0); - /* * Done if the on page value already appears on the update list. We can't do the same check * for stop time point because we may still need to append the onpage value if only the @@ -132,13 +126,8 @@ __rec_append_orig_value( if (WT_TIME_WINDOW_HAS_STOP(&unpack->tw)) { tombstone_globally_visible = __wt_txn_tw_stop_visible_all(session, &unpack->tw); - /* - * No need to append the tombstone if it is already in the update chain. - * - * Don't append the onpage tombstone if it is a prepared update as it is either on the - * update chain or has been aborted. If it is aborted, discard it silently. - */ - if (oldest_upd->type != WT_UPDATE_TOMBSTONE && !unpack->tw.prepare) { + /* No need to append the tombstone if it is already in the update chain. */ + if (oldest_upd->type != WT_UPDATE_TOMBSTONE) { /* * We still need to append the globally visible tombstone if its timestamp is WT_TS_NONE * as we may need it to clear the history store content of the key. We don't append a @@ -157,27 +146,17 @@ __rec_append_orig_value( F_SET(tombstone, WT_UPDATE_RESTORED_FROM_DS); } else { /* - * Once the prepared update is resolved, the in-memory update and on-disk written copy - * doesn't have same timestamp due to replacing of prepare timestamp with commit and - * durable timestamps. Don't compare them when the on-disk version is a prepare. - * * We may have overwritten its transaction id to WT_TXN_NONE and its timestamps to * WT_TS_NONE in the time window. */ - WT_ASSERT(session, unpack->tw.prepare || - ((unpack->tw.stop_ts == oldest_upd->start_ts || unpack->tw.stop_ts == WT_TS_NONE) && - (unpack->tw.stop_txn == oldest_upd->txnid || - unpack->tw.stop_txn == WT_TXN_NONE))); + WT_ASSERT(session, + (unpack->tw.stop_ts == oldest_upd->start_ts || unpack->tw.stop_ts == WT_TS_NONE) && + (unpack->tw.stop_txn == oldest_upd->txnid || unpack->tw.stop_txn == WT_TXN_NONE)); if (tombstone_globally_visible) return (0); } - } else if (unpack->tw.prepare) - /* - * Don't append the onpage value if it is a prepared update as it is either on the update - * chain or has been aborted. If it is aborted, discard it silently. - */ - return (0); + } /* We need the original on-page value for some reader: get a copy. */ if (!tombstone_globally_visible) { @@ -560,9 +539,13 @@ __wt_rec_upd_select(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins, v * part of the page, and they are physically removed by checkpoint writing this page, that is, * the checkpoint doesn't include the overflow blocks so they're removed and future readers of * this page won't be able to find them. + * + * We never append prepared updates back to the onpage value. If it is a prepared full update, + * it is already on the update chain. If it is a prepared tombstone, the onpage value is already + * appended to the update chain when the page is read into memory. */ if (upd_select->upd != NULL && vpack != NULL && vpack->type != WT_CELL_DEL && - (upd_saved || F_ISSET(vpack, WT_CELL_UNPACK_OVERFLOW))) + !vpack->tw.prepare && (upd_saved || F_ISSET(vpack, WT_CELL_UNPACK_OVERFLOW))) WT_ERR(__rec_append_orig_value(session, page, upd_select->upd, vpack)); __wt_time_window_clear_obsolete( -- cgit v1.2.1