CAMEL-24243: camel-aws2-athena - do not relaunch a still-running query when waitTimeout expires#25049
Open
oscerd wants to merge 1 commit into
Open
CAMEL-24243: camel-aws2-athena - do not relaunch a still-running query when waitTimeout expires#25049oscerd wants to merge 1 commit into
oscerd wants to merge 1 commit into
Conversation
…y when waitTimeout expires The inner wait loop in Athena2Producer.startQueryExecution exits on three conditions: success, failure/retry, and waitTimeout expiry. Only the first two set state on the helper, because setStatusFrom() assigns isSuccess/isFailure/ isRetry only for a completed query. So when the wait window elapsed while the query was still QUEUED or RUNNING, shouldAttempt() saw no completion state and returned true, and the outer loop submitted a brand-new Athena query. With maxAttempts > 1 that abandons the running execution -- still scanning, still billed -- and returns the queryExecutionId of the last submission, so the caller cannot correlate or cancel the earlier ones. clientRequestToken is not auto-generated, so Athena does not deduplicate them either. The documented contract is that attempts are consumed by retrying *failed* queries, not by queries that are merely slow. Treat waitTimeout expiry as terminal for the attempt loop, and keep consuming an attempt for a completed-and-retryable failure. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Andrea Cosentino <ancosen@gmail.com> (cherry picked from commit a2caf53)
davsclaus
approved these changes
Jul 23, 2026
gnodet
approved these changes
Jul 23, 2026
gnodet
left a comment
Contributor
There was a problem hiding this comment.
Clean backport of PR #25040 to camel-4.14.x. The fix correctly prevents shouldAttempt() from relaunching a still-running Athena query when waitTimeout expires.
Verified:
- Code changes are identical to the main branch fix and the 4.18.x backport (PR #25047)
- New
isWaitTimeoutExceeded()guard logic is correct: returns false whenattempts==0(no query submitted yet) or whenisRetryis true (completed-and-retryable query), and true only when wait timeout elapsed while query was still running - Both new tests are well-constructed and cover the key scenarios
- CI is fully green
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #25040 to
camel-4.14.x.When
startQueryExecution's inner wait loop exits becausewaitTimeoutelapsed while the query was still
QUEUED/RUNNING, no completion flag isset, so
shouldAttempt()returnedtrueand the outer loop resubmitted thesame SQL as a brand-new Athena query — orphaning (and continuing to bill) the
running one. The fix makes
shouldAttempt()treat wait-timeout expiry asterminal, while a completed-and-retryable failure still consumes an attempt.
The polling loop is identical on this branch. Cherry-picked with a trivial auto-merge on Athena2QueryHelper.java (this branch keeps its original Thread.sleep() doWait(); the fix only touches shouldAttempt());
Athena2QueryHelperTestpasses 24/24.No upgrade-guide entry — bug fix, no user-visible configuration change.
Claude Code on behalf of oscerd