diff options
author | samantharitter <samantha.ritter@10gen.com> | 2017-08-10 15:02:41 -0400 |
---|---|---|
committer | samantharitter <samantha.ritter@10gen.com> | 2017-08-10 17:38:54 -0400 |
commit | e1978af38dff725f0a0a60bca39a21b072751218 (patch) | |
tree | e2e4dcb138db49bbe2e069497ecb19ed753825a8 /src/mongo/db/logical_session_cache.cpp | |
parent | 1e1d27c271431f24cddcd2339151d7215c1178d1 (diff) | |
download | mongo-e1978af38dff725f0a0a60bca39a21b072751218.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; |