From 71971201f9aa5075e564a5b778f6715feaa61205 Mon Sep 17 00:00:00 2001 From: Luke Chen Date: Tue, 7 Dec 2021 17:47:10 +1100 Subject: Import wiredtiger: e64f50da5638af780fbcda89a85d34c6847b1241 from branch mongodb-4.4 ref: c45301668c..e64f50da56 for: 4.4.11 WT-8395 Inconsistent data after upgrade from 4.4.2-4.4.4 to 4.4.8+ and 5.0.2+ --- src/third_party/wiredtiger/INSTALL | 4 ++-- src/third_party/wiredtiger/README | 4 ++-- src/third_party/wiredtiger/RELEASE_INFO | 2 +- .../wiredtiger/build_posix/aclocal/version-set.m4 | 4 ++-- .../wiredtiger/build_posix/aclocal/version.m4 | 2 +- src/third_party/wiredtiger/import.data | 2 +- src/third_party/wiredtiger/src/conn/conn_api.c | 5 ++++ .../wiredtiger/src/include/connection.h | 8 +++++++ src/third_party/wiredtiger/src/meta/meta_turtle.c | 8 +++++-- src/third_party/wiredtiger/src/txn/txn_recover.c | 28 ++++++++++++++++++++++ .../wiredtiger/src/txn/txn_rollback_to_stable.c | 5 ++-- 11 files changed, 59 insertions(+), 13 deletions(-) diff --git a/src/third_party/wiredtiger/INSTALL b/src/third_party/wiredtiger/INSTALL index b4437c7e864..ef25361a312 100644 --- a/src/third_party/wiredtiger/INSTALL +++ b/src/third_party/wiredtiger/INSTALL @@ -1,6 +1,6 @@ -WiredTiger 10.0.1: (April 12, 2021) +WiredTiger 10.0.2: (November 30, 2021) -This is version 10.0.1 of WiredTiger. +This is version 10.0.2 of WiredTiger. Instructions for configuring, building, and installing WiredTiger are available online. diff --git a/src/third_party/wiredtiger/README b/src/third_party/wiredtiger/README index 57b9e083e23..df921a6d884 100644 --- a/src/third_party/wiredtiger/README +++ b/src/third_party/wiredtiger/README @@ -1,6 +1,6 @@ -WiredTiger 10.0.1: (April 12, 2021) +WiredTiger 10.0.2: (November 30, 2021) -This is version 10.0.1 of WiredTiger. +This is version 10.0.2 of WiredTiger. WiredTiger release packages and documentation can be found at: diff --git a/src/third_party/wiredtiger/RELEASE_INFO b/src/third_party/wiredtiger/RELEASE_INFO index 85f216a7850..954ca8646b1 100644 --- a/src/third_party/wiredtiger/RELEASE_INFO +++ b/src/third_party/wiredtiger/RELEASE_INFO @@ -1,6 +1,6 @@ WIREDTIGER_VERSION_MAJOR=10 WIREDTIGER_VERSION_MINOR=0 -WIREDTIGER_VERSION_PATCH=1 +WIREDTIGER_VERSION_PATCH=2 WIREDTIGER_VERSION="$WIREDTIGER_VERSION_MAJOR.$WIREDTIGER_VERSION_MINOR.$WIREDTIGER_VERSION_PATCH" WIREDTIGER_RELEASE_DATE=`date "+%B %e, %Y"` diff --git a/src/third_party/wiredtiger/build_posix/aclocal/version-set.m4 b/src/third_party/wiredtiger/build_posix/aclocal/version-set.m4 index f03a1f7819f..53dadedd6ad 100644 --- a/src/third_party/wiredtiger/build_posix/aclocal/version-set.m4 +++ b/src/third_party/wiredtiger/build_posix/aclocal/version-set.m4 @@ -2,8 +2,8 @@ dnl build by dist/s_version VERSION_MAJOR=10 VERSION_MINOR=0 -VERSION_PATCH=1 -VERSION_STRING='"WiredTiger 10.0.1: (April 12, 2021)"' +VERSION_PATCH=2 +VERSION_STRING='"WiredTiger 10.0.2: (November 30, 2021)"' AC_SUBST(VERSION_MAJOR) AC_SUBST(VERSION_MINOR) diff --git a/src/third_party/wiredtiger/build_posix/aclocal/version.m4 b/src/third_party/wiredtiger/build_posix/aclocal/version.m4 index c76126e107a..4e08838ca75 100644 --- a/src/third_party/wiredtiger/build_posix/aclocal/version.m4 +++ b/src/third_party/wiredtiger/build_posix/aclocal/version.m4 @@ -1,2 +1,2 @@ dnl WiredTiger product version for AC_INIT. Maintained by dist/s_version -10.0.1 +10.0.2 diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index ceff7ad6652..02b3327da2b 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.4", - "commit": "c45301668c5fd6856fffe99a1ed766e23977c517" + "commit": "e64f50da5638af780fbcda89a85d34c6847b1241" } diff --git a/src/third_party/wiredtiger/src/conn/conn_api.c b/src/third_party/wiredtiger/src/conn/conn_api.c index 2e55aedcd63..7859eba5e8a 100644 --- a/src/third_party/wiredtiger/src/conn/conn_api.c +++ b/src/third_party/wiredtiger/src/conn/conn_api.c @@ -2815,6 +2815,11 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler, const char *c WT_ERR(__wt_connection_open(conn, cfg)); session = conn->default_session; +#ifndef WT_STANDALONE_BUILD + /* Explicitly set the flag to indicate whether the database that was not shutdown cleanly. */ + conn->unclean_shutdown = false; +#endif + /* * This function expects the cache to be created so parse this after the rest of the connection * is set up. diff --git a/src/third_party/wiredtiger/src/include/connection.h b/src/third_party/wiredtiger/src/include/connection.h index 5b8f7e9f8e4..d4ee8add556 100644 --- a/src/third_party/wiredtiger/src/include/connection.h +++ b/src/third_party/wiredtiger/src/include/connection.h @@ -246,6 +246,14 @@ struct __wt_connection_impl { uint64_t hash_size; /* General hash bucket array size */ int is_new; /* Connection created database */ + uint32_t recovery_major; /* Database recovery major version */ + uint32_t recovery_minor; /* Database recovery minor version */ + uint32_t recovery_patch; /* Database recovery patch version */ + +#ifndef WT_STANDALONE_BUILD + bool unclean_shutdown; /* Flag to indicate the earlier shutdown status */ +#endif + uint16_t compat_major; /* Compatibility major version */ uint16_t compat_minor; /* Compatibility minor version */ #define WT_CONN_COMPAT_NONE UINT16_MAX diff --git a/src/third_party/wiredtiger/src/meta/meta_turtle.c b/src/third_party/wiredtiger/src/meta/meta_turtle.c index aa2e93623c9..309c80eaa05 100644 --- a/src/third_party/wiredtiger/src/meta/meta_turtle.c +++ b/src/third_party/wiredtiger/src/meta/meta_turtle.c @@ -153,7 +153,7 @@ int __wt_turtle_validate_version(WT_SESSION_IMPL *session) { WT_DECL_RET; - uint32_t major, minor; + uint32_t major, minor, patch; char *version_string; WT_WITH_TURTLE_LOCK( @@ -162,7 +162,7 @@ __wt_turtle_validate_version(WT_SESSION_IMPL *session) if (ret != 0) WT_ERR_MSG(session, ret, "Unable to read version string from turtle file"); - if ((ret = sscanf(version_string, "major=%u,minor=%u", &major, &minor)) != 2) + if ((ret = sscanf(version_string, "major=%u,minor=%u,patch=%u", &major, &minor, &patch)) != 3) WT_ERR_MSG(session, ret, "Unable to parse turtle file version string"); ret = 0; @@ -171,6 +171,10 @@ __wt_turtle_validate_version(WT_SESSION_IMPL *session) (major == WT_MIN_STARTUP_VERSION_MAJOR && minor < WT_MIN_STARTUP_VERSION_MINOR)) WT_ERR_MSG(session, WT_ERROR, "WiredTiger version incompatible with current binary"); + S2C(session)->recovery_major = major; + S2C(session)->recovery_minor = minor; + S2C(session)->recovery_patch = patch; + err: __wt_free(session, version_string); return (ret); diff --git a/src/third_party/wiredtiger/src/txn/txn_recover.c b/src/third_party/wiredtiger/src/txn/txn_recover.c index c76e2af3597..f401332e588 100644 --- a/src/third_party/wiredtiger/src/txn/txn_recover.c +++ b/src/third_party/wiredtiger/src/txn/txn_recover.c @@ -79,6 +79,14 @@ __recovery_cursor( WT_RET(__wt_open_cursor(session, r->files[id].uri, NULL, cfg, &c)); r->files[id].c = c; } +#ifndef WT_STANDALONE_BUILD + /* + * In the event of a clean shutdown, there shouldn't be any other table log records other + * than metadata. + */ + if (!metadata_op) + S2C(session)->unclean_shutdown = true; +#endif } if (duplicate && c != NULL) @@ -471,6 +479,14 @@ __recovery_set_checkpoint_snapshot(WT_SESSION_IMPL *session) conn = S2C(session); counter = 0; + /* + * WiredTiger versions 10.0.1 onward have a valid checkpoint snapshot on-disk. Ignore reading + * the on-disk checkpoint snapshot from older versions. + */ + if (conn->recovery_major < 10 || + (conn->recovery_major == 10 && conn->recovery_minor == 0 && conn->recovery_patch == 0)) + return (0); + /* * Read the system checkpoint information from the metadata file and save the snapshot related * details of the last checkpoint for later query. This gets saved in the connection. @@ -956,6 +972,18 @@ __wt_txn_recover(WT_SESSION_IMPL *session, const char *cfg[]) done: /* Close cached cursors, rollback-to-stable asserts exclusive access. */ WT_ERR(__recovery_close_cursors(&r)); +#ifndef WT_STANDALONE_BUILD + /* + * There is a known problem with upgrading from release 10.0.0 specifically. There are now fixes + * that can properly upgrade from 10.0.0 without hitting the problem but only from a clean + * shutdown of 10.0.0. Earlier releases are not affected by the upgrade issue. + */ + if (conn->unclean_shutdown && conn->recovery_major == 10 && conn->recovery_minor == 0 && + conn->recovery_patch == 0) + WT_ERR_MSG(session, WT_ERROR, + "Upgrading from a WiredTiger version 10.0.0 database that was not shutdown cleanly is " + "not allowed. Perform a clean shutdown on version 10.0.0 and then upgrade."); +#endif WT_ERR(__recovery_set_checkpoint_timestamp(&r)); WT_ERR(__recovery_set_oldest_timestamp(&r)); 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 6aee858e94b..2745497bddd 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 @@ -8,8 +8,9 @@ #include "wt_internal.h" -#define WT_CHECK_RECOVERY_FLAG_TXNID(session, txnid) \ - (F_ISSET(S2C(session), WT_CONN_RECOVERING) && (txnid) >= S2C(session)->recovery_ckpt_snap_min) +#define WT_CHECK_RECOVERY_FLAG_TXNID(session, txnid) \ + (F_ISSET(S2C(session), WT_CONN_RECOVERING) && S2C(session)->recovery_ckpt_snap_min != 0 && \ + (txnid) >= S2C(session)->recovery_ckpt_snap_min) /* Enable rollback to stable verbose messaging during recovery. */ #define WT_VERB_RECOVERY_RTS(session) \ -- cgit v1.2.1