From 0858b98deefaecb460392d76f8d84c3af0c306ce Mon Sep 17 00:00:00 2001 From: Liza K Date: Mon, 7 Dec 2020 20:36:03 +0200 Subject: [PATCH] INMEM_MAX_SESSIONS --- .../server/search/session/session_service.ts | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/x-pack/plugins/data_enhanced/server/search/session/session_service.ts b/x-pack/plugins/data_enhanced/server/search/session/session_service.ts index b7aaca8adfbfd..8ec41bd703d97 100644 --- a/x-pack/plugins/data_enhanced/server/search/session/session_service.ts +++ b/x-pack/plugins/data_enhanced/server/search/session/session_service.ts @@ -5,7 +5,6 @@ */ import moment, { Moment } from 'moment'; -import { orderBy } from 'lodash'; import { from, Observable } from 'rxjs'; import { first, switchMap } from 'rxjs/operators'; import { @@ -95,7 +94,7 @@ export class BackgroundSessionService implements ISessionService { .map((sessionId) => `"${sessionId}"`) .join(' | '); const res = await this.internalSavedObjectsClient.find({ - perPage: INMEM_MAX_SESSIONS, + perPage: INMEM_MAX_SESSIONS, // If there are more sessions in memory, they will be synced when some items are cleared out. type: BACKGROUND_SESSION_TYPE, search: activeMappingIds, searchFields: ['sessionId'], @@ -108,26 +107,6 @@ export class BackgroundSessionService implements ISessionService { private clearSessions = () => { const curTime = moment(); - // Drop old items if map size exceeds max. - if (this.sessionSearchMap.size > INMEM_MAX_SESSIONS) { - const sortedSessionIds = orderBy( - Array.from(this.sessionSearchMap.keys()).map((sessionId) => { - return { - sessionId, - insertTime: this.sessionSearchMap.get(sessionId)!.insertTime, - }; - }), - ['insertTime'], - ['asc'] - ); - - while (this.sessionSearchMap.size > INMEM_MAX_SESSIONS) { - const { sessionId } = sortedSessionIds.shift()!; - this.logger.warn(`clearSessions | Map full | Dropping ${sessionId}`); - this.sessionSearchMap.delete(sessionId); - } - } - this.sessionSearchMap.forEach((sessionInfo, sessionId) => { if ( moment.duration(curTime.diff(sessionInfo.insertTime)).asSeconds() >