Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in calculating when ad-hoc tasks are out of attempts (#192907)
In this PR, I'm fixing a bug where ad-hoc tasks would have one fewer attempts to retry in failure scenarios when using mget. ## To verify 1. Apply the following diff to your code ``` diff --git a/x-pack/plugins/stack_connectors/server/connector_types/server_log/index.ts b/x-pack/plugins/stack_connectors/server/connector_types/server_log/index.ts index 0275b2bdc2f..d481c3820a1 100644 --- a/x-pack/plugins/stack_connectors/server/connector_types/server_log/index.ts +++ b/x-pack/plugins/stack_connectors/server/connector_types/server_log/index.ts @@ -77,6 +77,10 @@ export function getConnectorType(): ServerLogConnectorType { async function executor( execOptions: ServerLogConnectorTypeExecutorOptions ): Promise<ConnectorTypeExecutorResult<void>> { + + console.log('*** Server log execution'); + throw new Error('Fail'); + const { actionId, params, logger } = execOptions; const sanitizedMessage = withoutControlCharacters(params.message); diff --git a/x-pack/plugins/task_manager/server/config.ts b/x-pack/plugins/task_manager/server/config.ts index db07494ef4f..07e277f8d16 100644 --- a/x-pack/plugins/task_manager/server/config.ts +++ b/x-pack/plugins/task_manager/server/config.ts @@ -202,7 +202,7 @@ export const configSchema = schema.object( max: 100, min: 1, }), - claim_strategy: schema.string({ defaultValue: CLAIM_STRATEGY_UPDATE_BY_QUERY }), + claim_strategy: schema.string({ defaultValue: CLAIM_STRATEGY_MGET }), request_timeouts: requestTimeoutsConfig, }, { diff --git a/x-pack/plugins/task_manager/server/lib/get_retry_at.ts b/x-pack/plugins/task_manager/server/lib/get_retry_at.ts index 278ba18642d..c8fb911d500 100644 --- a/x-pack/plugins/task_manager/server/lib/get_retry_at.ts +++ b/x-pack/plugins/task_manager/server/lib/get_retry_at.ts @@ -54,6 +54,7 @@ export function getRetryDate({ } export function calculateDelayBasedOnAttempts(attempts: number) { + return 10 * 1000; // Return 30s for the first retry attempt if (attempts === 1) { return 30 * 1000; ``` 2. Create an always firing rule that runs every hour, triggering a server log on check intervals 3. Let the rule run and observe the server log action running and failing three times (as compared to two)
- Loading branch information