Skip to content

Commit

Permalink
[ES|QL] Force ES client timeout after 2 minutes (elastic#168929)
Browse files Browse the repository at this point in the history
## Summary

We found out that for ES|QL queries while the kibana server (and
browser) timeouts in 2 minutes, the requests are still running in ES. So
instead of being aborted in 2 minutes, the hit a 5minute timeout from
the proxy which retries 3 times and then aborts.

This happens ONLY when bfetch is enabled (which is the default)

After an investigation with Rudolf it seems that we don't abort
correctly in bsearch. Lukas is fixing it here
elastic#169041 .
  • Loading branch information
stratoula authored and benakansara committed Oct 22, 2023
1 parent 5641454 commit caa2427
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import type { Logger } from '@kbn/core/server';
import { getKbnServerError, KbnServerError } from '@kbn/kibana-utils-plugin/server';
import type { ISearchStrategy } from '../../types';

const ES_TIMEOUT_IN_MS = 120000;

export const esqlSearchStrategyProvider = (
logger: Logger,
useInternalUser: boolean = false
Expand All @@ -23,6 +25,17 @@ export const esqlSearchStrategyProvider = (
* @returns `Observable<IEsSearchResponse<any>>`
*/
search: (request, { abortSignal, ...options }, { esClient, uiSettingsClient }) => {
const abortController = new AbortController();
// We found out that there are cases where we are not aborting correctly
// For this reasons we want to manually cancel he abort signal after 2 mins

abortSignal?.addEventListener('abort', () => {
abortController.abort();
});

// Also abort after two mins
setTimeout(() => abortController.abort(), ES_TIMEOUT_IN_MS);

// Only default index pattern type is supported here.
// See ese for other type support.
if (request.indexType) {
Expand All @@ -41,8 +54,10 @@ export const esqlSearchStrategyProvider = (
},
},
{
signal: abortSignal,
signal: abortController.signal,
meta: true,
// we don't want the ES client to retry (default value is 3)
maxRetries: 0,
}
);
return {
Expand Down

0 comments on commit caa2427

Please sign in to comment.