From 407ec649e0cfaee34883a398db5d8975954f519a Mon Sep 17 00:00:00 2001 From: Luke Chen Date: Tue, 11 Jan 2022 16:21:59 +1100 Subject: Import wiredtiger: e1427e4a69fa834ea3630523526379eaaef18c6c from branch mongodb-5.2 ref: 02329fa1d9..e1427e4a69 for: 5.2.0-rc5 WT-8598 Avoid checkpoint cleanup always on shutdown --- src/third_party/wiredtiger/import.data | 2 +- src/third_party/wiredtiger/src/btree/bt_sync.c | 4 ++-- src/third_party/wiredtiger/src/conn/conn_dhandle.c | 5 +++-- src/third_party/wiredtiger/src/include/connection.h | 4 ++-- src/third_party/wiredtiger/src/txn/txn.c | 7 +++++-- src/third_party/wiredtiger/src/txn/txn_ckpt.c | 7 ++----- src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c | 2 +- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index fc2b568e7d1..aa316802ab1 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.2", - "commit": "02329fa1d9ba292f5545d2adc67d4c324d0a2b04" + "commit": "e1427e4a69fa834ea3630523526379eaaef18c6c" } diff --git a/src/third_party/wiredtiger/src/btree/bt_sync.c b/src/third_party/wiredtiger/src/btree/bt_sync.c index df8dab28f4a..72b66ed006f 100644 --- a/src/third_party/wiredtiger/src/btree/bt_sync.c +++ b/src/third_party/wiredtiger/src/btree/bt_sync.c @@ -396,7 +396,7 @@ __sync_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, void *context, bool *ski } /* Don't read pages into cache during startup or shutdown phase. */ - if (F_ISSET(S2C(session), WT_CONN_RECOVERING | WT_CONN_CLOSING_TIMESTAMP)) { + if (F_ISSET(S2C(session), WT_CONN_RECOVERING | WT_CONN_CLOSING_CHECKPOINT)) { *skipp = true; return (0); } @@ -557,7 +557,7 @@ __wt_sync_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop) * reads all of the internal pages to improve cleanup). */ if (btree->type == BTREE_ROW) - internal_cleanup = !F_ISSET(conn, WT_CONN_RECOVERING | WT_CONN_CLOSING_TIMESTAMP); + internal_cleanup = !F_ISSET(conn, WT_CONN_RECOVERING | WT_CONN_CLOSING_CHECKPOINT); else { LF_SET(WT_READ_CACHE); internal_cleanup = false; diff --git a/src/third_party/wiredtiger/src/conn/conn_dhandle.c b/src/third_party/wiredtiger/src/conn/conn_dhandle.c index efe3a852ef7..3ed40c84d83 100644 --- a/src/third_party/wiredtiger/src/conn/conn_dhandle.c +++ b/src/third_party/wiredtiger/src/conn/conn_dhandle.c @@ -377,8 +377,9 @@ __wt_conn_dhandle_close(WT_SESSION_IMPL *session, bool final, bool mark_dead) * timestamp as needed and any remaining dirty data should be discarded. */ if (!discard && !marked_dead) { - if (F_ISSET(conn, WT_CONN_CLOSING_TIMESTAMP) || F_ISSET(conn, WT_CONN_IN_MEMORY) || - F_ISSET(btree, WT_BTREE_NO_CHECKPOINT)) + if ((F_ISSET(conn, WT_CONN_CLOSING_CHECKPOINT) && + conn->txn_global.has_stable_timestamp) || + F_ISSET(conn, WT_CONN_IN_MEMORY) || F_ISSET(btree, WT_BTREE_NO_CHECKPOINT)) discard = true; else { WT_TRET(__wt_checkpoint_close(session, final)); diff --git a/src/third_party/wiredtiger/src/include/connection.h b/src/third_party/wiredtiger/src/include/connection.h index bbd4db1a9ae..14fb4a17708 100644 --- a/src/third_party/wiredtiger/src/include/connection.h +++ b/src/third_party/wiredtiger/src/include/connection.h @@ -625,8 +625,8 @@ struct __wt_connection_impl { #define WT_CONN_CKPT_GATHER 0x000004u #define WT_CONN_CKPT_SYNC 0x000008u #define WT_CONN_CLOSING 0x000010u -#define WT_CONN_CLOSING_NO_MORE_OPENS 0x000020u -#define WT_CONN_CLOSING_TIMESTAMP 0x000040u +#define WT_CONN_CLOSING_CHECKPOINT 0x000020u +#define WT_CONN_CLOSING_NO_MORE_OPENS 0x000040u #define WT_CONN_COMPATIBILITY 0x000080u #define WT_CONN_DATA_CORRUPTION 0x000100u #define WT_CONN_EVICTION_RUN 0x000200u diff --git a/src/third_party/wiredtiger/src/txn/txn.c b/src/third_party/wiredtiger/src/txn/txn.c index d5e277f41ce..d519b514a4c 100644 --- a/src/third_party/wiredtiger/src/txn/txn.c +++ b/src/third_party/wiredtiger/src/txn/txn.c @@ -2369,8 +2369,10 @@ __wt_txn_global_shutdown(WT_SESSION_IMPL *session, const char **cfg) WT_SESSION_IMPL *s; char ts_string[WT_TS_INT_STRING_SIZE]; const char *ckpt_cfg; + bool use_timestamp; conn = S2C(session); + use_timestamp = false; /* * Perform a system-wide checkpoint so that all tables are consistent with each other. All @@ -2378,19 +2380,20 @@ __wt_txn_global_shutdown(WT_SESSION_IMPL *session, const char **cfg) * before shutting down all the subsystems. We have shut down all user sessions, but send in * true for waiting for internal races. */ + F_SET(conn, WT_CONN_CLOSING_CHECKPOINT); WT_TRET(__wt_config_gets(session, cfg, "use_timestamp", &cval)); ckpt_cfg = "use_timestamp=false"; if (cval.val != 0) { ckpt_cfg = "use_timestamp=true"; if (conn->txn_global.has_stable_timestamp) - F_SET(conn, WT_CONN_CLOSING_TIMESTAMP); + use_timestamp = true; } if (!F_ISSET(conn, WT_CONN_IN_MEMORY | WT_CONN_READONLY | WT_CONN_PANIC)) { /* * Perform rollback to stable to ensure that the stable version is written to disk on a * clean shutdown. */ - if (F_ISSET(conn, WT_CONN_CLOSING_TIMESTAMP)) { + if (use_timestamp) { __wt_verbose(session, WT_VERB_RTS, "performing shutdown rollback to stable with stable timestamp: %s", __wt_timestamp_to_string(conn->txn_global.stable_timestamp, ts_string)); diff --git a/src/third_party/wiredtiger/src/txn/txn_ckpt.c b/src/third_party/wiredtiger/src/txn/txn_ckpt.c index 31b01b21e3d..3981a09023a 100644 --- a/src/third_party/wiredtiger/src/txn/txn_ckpt.c +++ b/src/third_party/wiredtiger/src/txn/txn_ckpt.c @@ -352,11 +352,8 @@ __checkpoint_reduce_dirty_cache(WT_SESSION_IMPL *session) conn = S2C(session); cache = conn->cache; - /* - * Give up if scrubbing is disabled, including when checkpointing with a timestamp on close (we - * can't evict dirty pages in that case, so scrubbing cannot help). - */ - if (F_ISSET(conn, WT_CONN_CLOSING_TIMESTAMP) || cache->eviction_checkpoint_target < DBL_EPSILON) + /* Give up if scrubbing is disabled. */ + if (cache->eviction_checkpoint_target < DBL_EPSILON) return; time_start = __wt_clock(session); diff --git a/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c b/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c index 818eaf079c5..d23e0fe1ad4 100644 --- a/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c +++ b/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c @@ -1623,7 +1623,7 @@ __rollback_to_stable_btree_apply( * 2. Table has timestamped updates without a stable timestamp. */ if ((F_ISSET(S2C(session), WT_CONN_RECOVERING) || - F_ISSET(S2C(session), WT_CONN_CLOSING_TIMESTAMP)) && + F_ISSET(S2C(session), WT_CONN_CLOSING_CHECKPOINT)) && (addr_size == 0 || (rollback_timestamp == WT_TS_NONE && max_durable_ts != WT_TS_NONE))) { __wt_verbose_multi(session, WT_VERB_RECOVERY_RTS(session), "skip rollback to stable on file %s because %s", uri, -- cgit v1.2.1