summaryrefslogtreecommitdiff
path: root/src/mongo/db/logical_session_cache.cpp
diff options
context:
space:
mode:
authorsamantharitter <samantha.ritter@10gen.com>2017-08-10 15:02:41 -0400
committersamantharitter <samantha.ritter@10gen.com>2017-08-10 17:38:54 -0400
commite1978af38dff725f0a0a60bca39a21b072751218 (patch)
treee2e4dcb138db49bbe2e069497ecb19ed753825a8 /src/mongo/db/logical_session_cache.cpp
parent1e1d27c271431f24cddcd2339151d7215c1178d1 (diff)
downloadmongo-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.cpp13
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;