diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2018-04-09 11:11:00 -0400 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2018-04-11 14:44:49 -0400 |
commit | c6af07af7922c58293e86992ff9ef0a9ad77d398 (patch) | |
tree | 059aa2ad3aef63ac59f29cead17d2f1ed2328d0d /src/mongo | |
parent | 8a84d6bfd0b7e1446436d715df2b313d8363cc51 (diff) | |
download | mongo-c6af07af7922c58293e86992ff9ef0a9ad77d398.tar.gz |
SERVER-33241 Abort all open transactions on FCV downgrade
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/commands/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/commands/feature_compatibility_version.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/repl/SConscript | 2 |
3 files changed, 13 insertions, 3 deletions
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript index 206260fd7de..2d7a24f47ca 100644 --- a/src/mongo/db/commands/SConscript +++ b/src/mongo/db/commands/SConscript @@ -166,6 +166,7 @@ env.Library( LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/db/commands', '$BUILD_DIR/mongo/db/dbdirectclient', + '$BUILD_DIR/mongo/db/kill_sessions_local', ], ) diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp index b617228c4b7..2216c24dd6d 100644 --- a/src/mongo/db/commands/feature_compatibility_version.cpp +++ b/src/mongo/db/commands/feature_compatibility_version.cpp @@ -36,6 +36,7 @@ #include "mongo/db/commands/feature_compatibility_version_documentation.h" #include "mongo/db/commands/feature_compatibility_version_parser.h" #include "mongo/db/dbdirectclient.h" +#include "mongo/db/kill_sessions_local.h" #include "mongo/db/namespace_string.h" #include "mongo/db/operation_context.h" #include "mongo/db/repl/optime.h" @@ -153,8 +154,8 @@ void FeatureCompatibilityVersion::onInsertOrUpdate(OperationContext* opCtx, cons << FeatureCompatibilityVersionParser::toString(newVersion); } - // On commit, update the server parameters, and close any connections with a wire version that - // is below the minimum. + // On commit, update the server parameters, close any connections with a wire version that is + // below the minimum, and abort any open transactions if downgrading. opCtx->recoveryUnit()->onCommit([opCtx, newVersion]() { serverGlobalParams.featureCompatibility.setVersion(newVersion); updateMinWireVersion(); @@ -169,6 +170,14 @@ void FeatureCompatibilityVersion::onInsertOrUpdate(OperationContext* opCtx, cons executor::EgressTagCloserManager::get(opCtx->getServiceContext()) .dropConnections(transport::Session::kKeepOpen); } + + if (newVersion != ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo40) { + // Transactions are only allowed when the featureCompatibilityVersion is 4.0, so abort + // any open transactions when downgrading featureCompatibilityVersion. + SessionKiller::Matcher matcherAllSessions( + KillAllSessionsByPatternSet{makeKillAllSessionsByPattern(opCtx)}); + killSessionsLocalKillTransactions(opCtx, matcherAllSessions); + } }); } diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index fb0890b87a5..7da729365cd 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -1475,7 +1475,7 @@ env.CppUnitTest( ], LIBDEPS=[ '$BUILD_DIR/mongo/db/auth/authorization_manager_mock_init', - '$BUILD_DIR/mongo/db/commands/mongod_fcv', + '$BUILD_DIR/mongo/db/commands/feature_compatibility_parsers', '$BUILD_DIR/mongo/db/query/command_request_response', '$BUILD_DIR/mongo/executor/thread_pool_task_executor_test_fixture', '$BUILD_DIR/mongo/unittest/concurrency', |