diff options
author | Luke Chen <luke.chen@mongodb.com> | 2023-02-27 16:23:19 +1100 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-27 06:06:17 +0000 |
commit | d08a11d30691afb87b63329f43df1a81df610e8a (patch) | |
tree | 2774700710086909f1a1b864cd5281a8bead6e70 | |
parent | e29864141fe251a370fc1b223242ae846f6c4b17 (diff) | |
download | mongo-d08a11d30691afb87b63329f43df1a81df610e8a.tar.gz |
Import wiredtiger: c91f5a3e22d0acc1caf73b0114ced34828f7b631 from branch mongodb-6.3
ref: b7f971f04a..c91f5a3e22
for: 6.3.0-rc1
WT-10449 Do not save update chain when there are no updates to be written to the history store
-rw-r--r-- | src/third_party/wiredtiger/import.data | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/reconcile/rec_visibility.c | 57 |
2 files changed, 43 insertions, 16 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index 1def05e4b5d..1fa13b72f39 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-6.3", - "commit": "b7f971f04a0864fab42368d594251b3fb1d36477" + "commit": "c91f5a3e22d0acc1caf73b0114ced34828f7b631" } diff --git a/src/third_party/wiredtiger/src/reconcile/rec_visibility.c b/src/third_party/wiredtiger/src/reconcile/rec_visibility.c index 8668806355a..9765369f314 100644 --- a/src/third_party/wiredtiger/src/reconcile/rec_visibility.c +++ b/src/third_party/wiredtiger/src/reconcile/rec_visibility.c @@ -252,9 +252,12 @@ __rec_find_and_save_delete_hs_upd(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_ * Return if we need to save the update chain */ static inline bool -__rec_need_save_upd( - WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_UPDATE_SELECT *upd_select, bool has_newer_updates) +__rec_need_save_upd(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_UPDATE_SELECT *upd_select, + WT_CELL_UNPACK_KV *vpack, bool has_newer_updates) { + WT_UPDATE *upd; + bool supd_restore, visible_all; + if (upd_select->tw.prepare) return (true); @@ -278,9 +281,33 @@ __rec_need_save_upd( return (false); if (WT_TIME_WINDOW_HAS_STOP(&upd_select->tw)) - return (!__wt_txn_tw_stop_visible_all(session, &upd_select->tw)); + visible_all = __wt_txn_tw_stop_visible_all(session, &upd_select->tw); else - return (!__wt_txn_tw_start_visible_all(session, &upd_select->tw)); + visible_all = __wt_txn_tw_start_visible_all(session, &upd_select->tw); + + if (visible_all) + return (false); + + /* + * Update chains are only need to be saved when there are: + * 1. Newer uncommitted updates or database is configured for in-memory storage. + * 2. On-disk entry exists. + * 3. Valid updates exist in the update chain to be written to the history store. + */ + supd_restore = + F_ISSET(r, WT_REC_EVICT) && (has_newer_updates || F_ISSET(S2C(session), WT_CONN_IN_MEMORY)); + + if (!supd_restore && vpack == NULL && upd_select->upd != NULL) { + upd = upd_select->upd; + while (upd->next != NULL) { + upd = upd->next; + if (upd->txnid != WT_TXN_ABORTED) + return (true); + } + return (false); + } + + return (true); } /* @@ -902,7 +929,7 @@ __wt_rec_upd_select(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins, W * * Additionally history store reconciliation is not set skip saving an update. */ - if (__rec_need_save_upd(session, r, upd_select, has_newer_updates)) { + if (__rec_need_save_upd(session, r, upd_select, vpack, has_newer_updates)) { /* * We should restore the update chains to the new disk image if there are newer updates in * eviction, or for cases that don't support history store, such as an in-memory database. @@ -913,20 +940,20 @@ __wt_rec_upd_select(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins, W upd_memsize = __rec_calc_upd_memsize(onpage_upd, upd_select->tombstone, upd_memsize); WT_RET(__rec_update_save( session, r, ins, rip, onpage_upd, upd_select->tombstone, supd_restore, upd_memsize)); - - /* - * Mark the selected update (and potentially the tombstone preceding it) as being destined - * for the data store. Subsequent reconciliations should know that they can select this - * update regardless of visibility. - */ - if (upd_select->upd != NULL) - F_SET(upd_select->upd, WT_UPDATE_DS); - if (upd_select->tombstone != NULL) - F_SET(upd_select->tombstone, WT_UPDATE_DS); upd_saved = upd_select->upd_saved = true; } /* + * Mark the selected update (and potentially the tombstone preceding it) as being destined for + * the data store. Subsequent reconciliations should know that they can select this update + * regardless of visibility. + */ + if (upd_select->upd != NULL) + F_SET(upd_select->upd, WT_UPDATE_DS); + if (upd_select->tombstone != NULL) + F_SET(upd_select->tombstone, WT_UPDATE_DS); + + /* * Set statistics for update restore evictions. Update restore eviction debug mode forces update * restores to both committed or uncommitted changes. */ |