void handleLsid(const LogicalSessionId& lsid) { // There are some lifetime issues with when the reaper starts up versus when the grid is // available. Moving routing info fetching until after we have a transaction moves us past // the problem. // // Also, we should only need the chunk case, but that'll wait until the sessions table is // actually sharded. if (!(_cm || _primary)) { auto routingInfo = uassertStatusOK(Grid::get(_opCtx)->catalogCache()->getCollectionRoutingInfo( _opCtx, SessionsCollection::kSessionsNamespaceString)); _cm = routingInfo.cm(); _primary = routingInfo.db().primary(); } ShardId shardId; if (_cm) { const auto chunk = _cm->findIntersectingChunkWithSimpleCollation(lsid.toBSON()); shardId = chunk.getShardId(); } else { shardId = _primary->getId(); } auto& lsids = _shards[shardId]; lsids.insert(lsid); if (lsids.size() > write_ops::kMaxWriteBatchSize) { _numReaped += removeSessionsRecords(_opCtx, _sessionsCollection, lsids); _shards.erase(shardId); } }
void handleLsid(const LogicalSessionId& lsid) { invariant(_cm); const auto chunk = _cm->findIntersectingChunkWithSimpleCollation(lsid.toBSON()); const auto shardId = chunk.getShardId(); auto& lsids = _shards[shardId]; lsids.insert(lsid); if (lsids.size() >= write_ops::kMaxWriteBatchSize) { _numReaped += removeSessionsRecords(_opCtx, _sessionsCollection, lsids); _shards.erase(shardId); } }