summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlake Oler <blake.oler@mongodb.com>2018-11-29 16:24:05 -0500
committerBlake Oler <blake.oler@mongodb.com>2018-12-10 16:30:00 -0500
commit55fe7608091791ff5b46de3c15fbf368268128f4 (patch)
tree7df32386897c03336c57110879176ec8452d2368
parenta3ed66ac2e610a2eb9dff192484f65860dda2ece (diff)
downloadmongo-55fe7608091791ff5b46de3c15fbf368268128f4.tar.gz
SERVER-36349 Prevent ClusterWrite errors from affecting the OperationShardingState's error handling
(cherry picked from commit be673d00e71fe975fe9fe934ce719ff9d27a2712)
-rw-r--r--src/mongo/db/SConscript1
-rw-r--r--src/mongo/db/logical_session_cache_impl.cpp16
2 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index 5f337d4ac4e..27384af73fd 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -1370,6 +1370,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()) {