-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Explain Log Rate Spikes: Make use of abort signal for ES queries. (
#143683) So far we passed on the abort signal from the client to possibly cancel the analysis, but the signal was not passed on to the ES queries to cancel those. That means the analysis could be cancelled after each step but it did not cancel ES queries that were already running. This PR takes the already existing abort signal and passes it on to all ES queries. This surfaced an issue with running too many queries in parallel: We didn't have a limit so far when fetching the histogram data. With using the abort signals, Kibana would report a warning if more than 10 queries were run at once. The PR updates fetching histogram data to also do it in chunks of 10 queries like we already do for the p-value aggregation. So the larger bulk of the file diff is the result of wrapping the histogram queries inside a for of to iterate over the chunks of queries.
- Loading branch information
Showing
8 changed files
with
324 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/aiops/server/lib/is_request_aborted_error.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { isRequestAbortedError } from './is_request_aborted_error'; | ||
|
||
describe('isRequestAbortedError', () => { | ||
it('returns false for a string', () => { | ||
expect(isRequestAbortedError('the-error')).toBe(false); | ||
}); | ||
it('returns false for a an object without a name field', () => { | ||
expect(isRequestAbortedError({ error: 'the-error' })).toBe(false); | ||
}); | ||
it(`returns false for a an object with a name field other than 'RequestAbortedError'`, () => { | ||
expect(isRequestAbortedError({ name: 'the-error' })).toBe(false); | ||
}); | ||
it(`returns true for a an object with a name field that contains 'RequestAbortedError'`, () => { | ||
expect(isRequestAbortedError({ name: 'RequestAbortedError' })).toBe(true); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
x-pack/plugins/aiops/server/lib/is_request_aborted_error.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { isPopulatedObject } from '@kbn/ml-is-populated-object'; | ||
|
||
interface RequestAbortedError extends Error { | ||
name: 'RequestAbortedError'; | ||
} | ||
|
||
export function isRequestAbortedError(arg: unknown): arg is RequestAbortedError { | ||
return isPopulatedObject(arg, ['name']) && arg.name === 'RequestAbortedError'; | ||
} |
Oops, something went wrong.