summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordi Serra Torrens <jordi.serra-torrens@mongodb.com>2022-01-07 11:58:01 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-07 12:25:25 +0000
commit6f8b7bd312e36b71990b32dda44d2511a27aa386 (patch)
tree2289b2985b62612c99abd573bd98fa7bda196430
parent05cf9f1fd13bedf9ad9a421d6ee8ad98351b4a06 (diff)
downloadmongo-6f8b7bd312e36b71990b32dda44d2511a27aa386.tar.gz
SERVER-62281 Ensure drain of migrations pending recovery on FCV upgrade/downgrade
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
index 117137a7c79..b137279d485 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -65,6 +65,7 @@
#include "mongo/db/repl/tenant_migration_recipient_service.h"
#include "mongo/db/s/active_migrations_registry.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
+#include "mongo/db/s/migration_util.h"
#include "mongo/db/s/resharding/coordinator_document_gen.h"
#include "mongo/db/s/resharding/resharding_coordinator_service.h"
#include "mongo/db/s/resharding/resharding_donor_recipient_common.h"
@@ -334,8 +335,14 @@ public:
if (feature_flags::gFeatureFlagMigrationRecipientCriticalSection.isEnabledOnVersion(
actualVersion) &&
!feature_flags::gFeatureFlagMigrationRecipientCriticalSection
- .isEnabledOnVersion(requestedVersion))
- drainNewMoveChunks.emplace(opCtx, "setFeatureCompatibilityVersionUpgrade");
+ .isEnabledOnVersion(requestedVersion)) {
+ drainNewMoveChunks.emplace(opCtx, "setFeatureCompatibilityVersionDowngrade");
+
+ // At this point, because we are holding the MigrationBlockingGuard, no new
+ // migrations can start and there are no active ongoing ones. Still, there could
+ // be migrations pending recovery. Drain them.
+ migrationutil::drainMigrationsPendingRecovery(opCtx);
+ }
// Start transition to 'requestedVersion' by updating the local FCV document to a
// 'kUpgrading' or 'kDowngrading' state, respectively.
@@ -375,9 +382,15 @@ public:
if (!feature_flags::gFeatureFlagMigrationRecipientCriticalSection.isEnabledOnVersion(
actualVersion) &&
feature_flags::gFeatureFlagMigrationRecipientCriticalSection.isEnabledOnVersion(
- requestedVersion))
+ requestedVersion)) {
drainOldMoveChunks.emplace(opCtx, "setFeatureCompatibilityVersionUpgrade");
+ // At this point, because we are holding the MigrationBlockingGuard, no new
+ // migrations can start and there are no active ongoing ones. Still, there could
+ // be migrations pending recovery. Drain them.
+ migrationutil::drainMigrationsPendingRecovery(opCtx);
+ }
+
// Complete transition by updating the local FCV document to the fully upgraded or
// downgraded requestedVersion.
const auto fcvChangeRegion(FeatureCompatibilityVersion::enterFCVChangeRegion(opCtx));