diff options
author | samantharitter <samantha.ritter@10gen.com> | 2017-08-10 15:02:41 -0400 |
---|---|---|
committer | samantharitter <samantha.ritter@10gen.com> | 2017-08-14 14:45:47 -0400 |
commit | 75713137374ad9d134951adec5cb963b5ba32a66 (patch) | |
tree | 30cda74ca702717bccbf0a1dd252d955248b30a6 /src/mongo/db/logical_session_cache.cpp | |
parent | 530c50d569e72170007ba0061a43758c873bab3b (diff) | |
download | mongo-75713137374ad9d134951adec5cb963b5ba32a66.tar.gz |
SERVER-29202 Add a refreshLogicalSessionCacheNow test command
Diffstat (limited to 'src/mongo/db/logical_session_cache.cpp')
-rw-r--r-- | src/mongo/db/logical_session_cache.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mongo/db/logical_session_cache.cpp b/src/mongo/db/logical_session_cache.cpp index 7baeb66593d..fb3518ada63 100644 --- a/src/mongo/db/logical_session_cache.cpp +++ b/src/mongo/db/logical_session_cache.cpp @@ -226,8 +226,17 @@ void LogicalSessionCache::_refresh(Client* client) { // failed to refresh, it means their authoritative records were removed, and // we should remove such records from our cache as well. { - auto opCtx = client->makeOperationContext(); - auto res = _sessionsColl->refreshSessions(opCtx.get(), std::move(activeSessions), time); + boost::optional<ServiceContext::UniqueOperationContext> uniqueCtx; + auto* const opCtx = [&client, &uniqueCtx] { + if (client->getOperationContext()) { + return client->getOperationContext(); + } + + uniqueCtx.emplace(client->makeOperationContext()); + return uniqueCtx->get(); + }(); + + auto res = _sessionsColl->refreshSessions(opCtx, std::move(activeSessions), time); if (!res.isOK()) { // TODO SERVER-29709: handle network errors here. return; |