diff options
author | Blake Oler <blake.oler@mongodb.com> | 2018-11-29 16:24:05 -0500 |
---|---|---|
committer | Blake Oler <blake.oler@mongodb.com> | 2018-12-03 14:31:00 -0500 |
commit | be673d00e71fe975fe9fe934ce719ff9d27a2712 (patch) | |
tree | 2e791a94e5656c65255e88e2863b6fd5febfd341 | |
parent | 67d78e413592a31a95eac8b095d7fa7ffbe94021 (diff) | |
download | mongo-be673d00e71fe975fe9fe934ce719ff9d27a2712.tar.gz |
SERVER-36349 Prevent ClusterWrite errors from affecting the OperationShardingState's error handling
-rw-r--r-- | src/mongo/db/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/logical_session_cache_impl.cpp | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript index 977c85720c2..5665e8b25f4 100644 --- a/src/mongo/db/SConscript +++ b/src/mongo/db/SConscript @@ -1406,6 +1406,7 @@ env.Library( ], LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/db/commands/server_status', + '$BUILD_DIR/mongo/db/s/sharding_api_d', ] ) diff --git a/src/mongo/db/logical_session_cache_impl.cpp b/src/mongo/db/logical_session_cache_impl.cpp index 1b32ed8d3cc..ce5a013f20f 100644 --- a/src/mongo/db/logical_session_cache_impl.cpp +++ b/src/mongo/db/logical_session_cache_impl.cpp @@ -37,6 +37,7 @@ #include "mongo/db/logical_session_id.h" #include "mongo/db/logical_session_id_helpers.h" #include "mongo/db/operation_context.h" +#include "mongo/db/s/operation_sharding_state.h" #include "mongo/db/server_parameters.h" #include "mongo/db/service_context.h" #include "mongo/platform/atomic_word.h" @@ -47,6 +48,17 @@ namespace mongo { +namespace { + +void clearShardingOperationFailedStatus(OperationContext* opCtx) { + // We do not intend to immediately act upon sharding errors if we receive them during sessions + // collection operations. We will instead attempt the same operations during the next refresh + // cycle. + OperationShardingState::get(opCtx).resetShardingOperationFailedStatus(); +} + +} // namespace + MONGO_EXPORT_STARTUP_SERVER_PARAMETER( logicalSessionRefreshMillis, int, @@ -221,6 +233,8 @@ Status LogicalSessionCacheImpl::_reap(Client* client) { return uniqueCtx->get(); }(); + ON_BLOCK_EXIT([&opCtx] { clearShardingOperationFailedStatus(opCtx); }); + auto existsStatus = _sessionsColl->checkSessionsCollectionExists(opCtx); if (!existsStatus.isOK()) { StringData notSetUpWarning = @@ -292,6 +306,8 @@ void LogicalSessionCacheImpl::_refresh(Client* client) { return uniqueCtx->get(); }(); + ON_BLOCK_EXIT([&opCtx] { clearShardingOperationFailedStatus(opCtx); }); + auto setupStatus = _sessionsColl->setupSessionsCollection(opCtx); if (!setupStatus.isOK()) { |