-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Search Sessions] Monitoring hardening part 1 #96196
Changes from 6 commits
c51d5fd
0cb55f6
af9f767
b5e74dd
5e488cc
fd68d01
fb72103
a3ac094
4ad1c4a
6922cee
511ada5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ import { checkRunningSessions } from './check_running_sessions'; | |
import { CoreSetup, SavedObjectsClient, Logger } from '../../../../../../src/core/server'; | ||
import { ConfigSchema } from '../../../config'; | ||
import { SEARCH_SESSION_TYPE } from '../../../common'; | ||
import { DataEnhancedStartDependencies } from '../../type'; | ||
|
||
export const SEARCH_SESSIONS_TASK_TYPE = 'search_sessions_monitor'; | ||
export const SEARCH_SESSIONS_TASK_ID = `data_enhanced_${SEARCH_SESSIONS_TASK_TYPE}`; | ||
|
@@ -25,12 +26,20 @@ interface SearchSessionTaskDeps { | |
config: ConfigSchema; | ||
} | ||
|
||
function searchSessionRunner(core: CoreSetup, { logger, config }: SearchSessionTaskDeps) { | ||
function searchSessionRunner( | ||
core: CoreSetup<DataEnhancedStartDependencies>, | ||
{ logger, config }: SearchSessionTaskDeps | ||
) { | ||
return ({ taskInstance }: RunContext) => { | ||
return { | ||
async run() { | ||
const sessionConfig = config.search.sessions; | ||
const [coreStart] = await core.getStartServices(); | ||
const [coreStart, pluginsStart] = await core.getStartServices(); | ||
if (!sessionConfig.enabled) { | ||
logger.info('Search sessions are disabled. Clearing task.'); | ||
await pluginsStart.taskManager.removeIfExists(SEARCH_SESSIONS_TASK_ID); | ||
lizozom marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gmmorris (or someone else who another task manager expert :D ), could you please review? (If this already hasn't been discussed somewhere) 🙏 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oooh I do not know about this 😬 I suspect you'll see that if you add an end to end test that verifies this behaviour. What are we trying to achieve here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what we try to achieve:
Currently, this is not happening in master. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gmmorris Updated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
return; | ||
} | ||
const internalRepo = coreStart.savedObjects.createInternalRepository([SEARCH_SESSION_TYPE]); | ||
const internalSavedObjectsClient = new SavedObjectsClient(internalRepo); | ||
await checkRunningSessions( | ||
|
@@ -50,7 +59,10 @@ function searchSessionRunner(core: CoreSetup, { logger, config }: SearchSessionT | |
}; | ||
} | ||
|
||
export function registerSearchSessionsTask(core: CoreSetup, deps: SearchSessionTaskDeps) { | ||
export function registerSearchSessionsTask( | ||
core: CoreSetup<DataEnhancedStartDependencies>, | ||
deps: SearchSessionTaskDeps | ||
) { | ||
deps.taskManager.registerTaskDefinitions({ | ||
[SEARCH_SESSIONS_TASK_TYPE]: { | ||
title: 'Search Sessions Monitor', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned this in the other issue as well, but what are we hoping to accomplish by processing these serially rather than in parallel? The main issue of concern seemed to be that the update request is too large, so the only benefits I can see with serially are a decrease in CPU/memory, but I'm not sure if that will outweigh the fact that this change may also make the process take much longer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole idea of paging the sessions was to update the items in reasonable amounts and in orderly fashion.
With
mergeMap
we weren't doing that.I think that serializing bulks of 100 search sessions makes sense, but it's going to be hard to quantify the impact.
Not 100% the same (more related to reducing the page size), but the article @Dosant linked convinced me https://eng.lifion.com/promise-allpocalypse-cfb6741298a7?gi=2c3ce0dba6ea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukasolson, I think there is also a difference between grouping per 100 requests or sending all of them to ES? with
concatMap
we spread out the load.