Status SessionsCollectionRS::setupSessionsCollection(OperationContext* opCtx) { return dispatch( NamespaceString::kLogicalSessionsNamespace, opCtx, [&] { auto existsStatus = checkSessionsCollectionExists(opCtx); if (existsStatus.isOK()) { return Status::OK(); } DBDirectClient client(opCtx); BSONObj cmd; if (existsStatus.code() == ErrorCodes::IndexOptionsConflict) { cmd = generateCollModCmd(); } else { // Creating the TTL index will auto-generate the collection. cmd = generateCreateIndexesCmd(); } BSONObj info; if (!client.runCommand( NamespaceString::kLogicalSessionsNamespace.db().toString(), cmd, info)) { return getStatusFromCommandResult(info); } return Status::OK(); }, [&](DBClientBase*) { return checkSessionsCollectionExists(opCtx); }); }
Status SessionsCollectionRS::setupSessionsCollection(OperationContext* opCtx) { return dispatch( NamespaceString::kLogicalSessionsNamespace, opCtx, [&] { // Creating the TTL index will auto-generate the collection. DBDirectClient client(opCtx); BSONObj info; auto cmd = generateCreateIndexesCmd(); if (!client.runCommand( NamespaceString::kLogicalSessionsNamespace.db().toString(), cmd, info)) { return getStatusFromCommandResult(info); } return Status::OK(); }, [&](DBClientBase*) { return checkSessionsCollectionExists(opCtx); }); }