summaryrefslogtreecommitdiff
path: root/src/mongo/db/op_observer_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/op_observer_impl.cpp')
-rw-r--r--src/mongo/db/op_observer_impl.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp
index 23e0f7427a4..7b106277c61 100644
--- a/src/mongo/db/op_observer_impl.cpp
+++ b/src/mongo/db/op_observer_impl.cpp
@@ -52,6 +52,8 @@
#include "mongo/db/server_options.h"
#include "mongo/db/session_catalog.h"
#include "mongo/db/views/durable_view_catalog.h"
+#include "mongo/s/client/shard_registry.h"
+#include "mongo/s/grid.h"
#include "mongo/scripting/engine.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/fail_point_service.h"
@@ -982,6 +984,19 @@ void OpObserverImpl::onReplicationRollback(OperationContext* opCtx,
if (rbInfo.shardIdentityRolledBack) {
fassertFailedNoTrace(50712);
}
+
+ // 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);
+ }
+ }
}
} // namespace mongo