Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,47 +115,4 @@ describe('catchRetryableSearchPhaseExecutionException', () => {
}
`);
});
it('retries search phase execution exception for "all shards failed"', async () => {
const error = new esErrors.ResponseError(
elasticsearchClientMock.createApiResponse({
body: {
error: {
type: 'search_phase_execution_exception',
caused_by: {
type: 'search_phase_execution_exception',
reason: 'all shards failed',
},
},
},
})
);
expect(
((await Promise.reject(error).catch(catchRetryableSearchPhaseExecutionException)) as any).left
).toMatchInlineSnapshot(`
Object {
"error": [ResponseError: search_phase_execution_exception
Caused by:
search_phase_execution_exception: all shards failed],
"message": "search_phase_execution_exception
Caused by:
search_phase_execution_exception: all shards failed",
"type": "retryable_es_client_error",
}
`);
});
it('does not retry other errors', async () => {
const error = new esErrors.ResponseError(
elasticsearchClientMock.createApiResponse({
body: {
error: {
type: 'search_phase_execution_exception',
reason: 'Malformed search query.',
},
},
})
);
await expect(
Promise.reject(error).catch(catchRetryableSearchPhaseExecutionException)
).rejects.toBe(error);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ const retryResponseStatuses = [
504, // GatewayTimeout
];

const temporarySearchPhaseExecutionExceptionReasons = [
'Search rejected due to missing shards',
'all shards failed',
];

export const catchRetryableEsClientErrors = (
e: EsErrors.ElasticsearchClientError
): Either.Either<RetryableEsClientError, never> => {
Expand All @@ -52,12 +47,7 @@ export const catchRetryableEsClientErrors = (
export const catchRetryableSearchPhaseExecutionException = (
e: EsErrors.ResponseError
): Either.Either<RetryableEsClientError, never> => {
if (
e?.body?.error?.type === 'search_phase_execution_exception' &&
temporarySearchPhaseExecutionExceptionReasons.some((reason) =>
e?.body?.error?.caused_by?.reason?.includes(reason)
)
) {
if (e?.body?.error?.type === 'search_phase_execution_exception') {
return Either.left({
type: 'retryable_es_client_error' as const,
message: e?.message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ export const waitForPickupUpdatedMappingsTask = flow(
);
} else if (Option.isSome(res.error)) {
const error = res.error.value;
if (
error.type === 'search_phase_execution_exception' &&
error.caused_by?.reason?.includes('Search rejected due to missing shards')
) {
if (error.type === 'search_phase_execution_exception') {
// This error is normally fixed in the next try, so let's retry
// the update mappings task instead of throwing
return TaskEither.left({
Expand Down