diff options
author | Misha Tyulenev <misha@mongodb.com> | 2018-07-26 18:47:04 -0400 |
---|---|---|
committer | Misha Tyulenev <misha@mongodb.com> | 2018-07-26 18:47:31 -0400 |
commit | 1dd7544c6db8b7def577400a3ec354d5cc8a9c97 (patch) | |
tree | 263851bc4d85da9c852f434c01c3cb6527804222 | |
parent | c280a1829dbaf65b7fbb5bc93762776817fceae5 (diff) | |
download | mongo-1dd7544c6db8b7def577400a3ec354d5cc8a9c97.tar.gz |
SERVER-36248 Do not reject sessions in FCV 3.4
-rw-r--r-- | src/mongo/db/initialize_operation_session_info.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/mongo/db/initialize_operation_session_info.cpp b/src/mongo/db/initialize_operation_session_info.cpp index a6ab3081708..15403627546 100644 --- a/src/mongo/db/initialize_operation_session_info.cpp +++ b/src/mongo/db/initialize_operation_session_info.cpp @@ -26,6 +26,8 @@ * then also delete it in the license file. */ +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault + #include "mongo/platform/basic.h" #include "mongo/db/initialize_operation_session_info.h" @@ -35,6 +37,7 @@ #include "mongo/db/logical_session_cache.h" #include "mongo/db/logical_session_id_helpers.h" #include "mongo/db/operation_context.h" +#include "mongo/util/log.h" namespace mongo { @@ -63,22 +66,26 @@ Status initializeOperationSessionInfo(OperationContext* opCtx, bool isFCV36 = (serverGlobalParams.featureCompatibility.getVersion() == ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo36); - if (osi.getSessionId()) { - if (!isFCV36) { - return SessionsCommandFCV34Status("Sessions"); - } - + // For the drivers it will look like the session is successfully added in FCV 3.4. + if (osi.getSessionId() && isFCV36) { stdx::lock_guard<Client> lk(*opCtx->getClient()); opCtx->setLogicalSessionId(makeLogicalSessionId(osi.getSessionId().get(), opCtx)); LogicalSessionCache* lsc = LogicalSessionCache::get(opCtx->getServiceContext()); - uassertStatusOK(lsc->vivify(opCtx, opCtx->getLogicalSessionId().get())); + auto vivifyStatus = lsc->vivify(opCtx, opCtx->getLogicalSessionId().get()); + if (vivifyStatus != Status::OK()) { + return vivifyStatus; + } } if (osi.getTxnNumber()) { stdx::lock_guard<Client> lk(*opCtx->getClient()); + if (!isFCV36) { + return SessionsCommandFCV34Status("Retryable writes"); + } + if (!opCtx->getLogicalSessionId()) { return {ErrorCodes::IllegalOperation, "Transaction number requires a sessionId to be specified"}; @@ -100,13 +107,13 @@ Status initializeOperationSessionInfo(OperationContext* opCtx, return {ErrorCodes::BadValue, "Transaction number cannot be negative"}; } - if (!isFCV36) { - return SessionsCommandFCV34Status("Retryable writes"); - } - opCtx->setTxnNumber(*osi.getTxnNumber()); } + if (!isFCV36) { + log() << "Using sessions while not fully upgraded to FCV3.6"; + } + return Status::OK(); } |