diff options
author | Misha Tyulenev <misha@mongodb.com> | 2018-12-11 11:23:39 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-27 17:25:34 +0000 |
commit | 35f4172754bec2cc62115f96af14366bf2b8ca1a (patch) | |
tree | 27bdc9bd86f857b7246451b5b49b845411e1fcd6 /src/mongo/db/repl | |
parent | be0eb178a1c599497a307a5b114d112343fab9c1 (diff) | |
download | mongo-35f4172754bec2cc62115f96af14366bf2b8ca1a.tar.gz |
SERVER-37929 reload ShardRegistry on config servers on rollback
(cherry picked from commit fc1b17cfdeffa13b5326050893658e7ba4df57a1)
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r-- | src/mongo/db/repl/rs_rollback.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index f1a9c2d3493..65ba8fff86b 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -73,6 +73,8 @@ #include "mongo/db/repl/rslog.h" #include "mongo/db/s/shard_identity_rollback_notifier.h" #include "mongo/db/session_catalog.h" +#include "mongo/s/client/shard_registry.h" +#include "mongo/s/grid.h" #include "mongo/util/exit.h" #include "mongo/util/fail_point_service.h" #include "mongo/util/log.h" @@ -1465,6 +1467,19 @@ void rollback_internal::syncFixUp(OperationContext* opCtx, validator->resetKeyManagerCache(); } + // The code below will force the config server to update its shard registry. + // Otherwise it may have the stale data that has been just rolled back. + if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) { + if (auto shardRegistry = Grid::get(opCtx)->shardRegistry()) { + auto& readConcernArgs = repl::ReadConcernArgs::get(opCtx); + ON_BLOCK_EXIT([ argsCopy = readConcernArgs, &readConcernArgs ] { + readConcernArgs = std::move(argsCopy); + }); + readConcernArgs = repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern); + shardRegistry->reload(opCtx); + } + } + // Reload the lastAppliedOpTime and lastDurableOpTime value in the replcoord and the // lastAppliedHash value in bgsync to reflect our new last op. The rollback common point does // not necessarily represent a consistent database state. For example, on a secondary, we may |