Skip to content

CAMEL-24243: camel-aws2-athena - do not relaunch a still-running query when waitTimeout expires#25049

Open
oscerd wants to merge 1 commit into
apache:camel-4.14.xfrom
oscerd:backport/CAMEL-24243-414
Open

CAMEL-24243: camel-aws2-athena - do not relaunch a still-running query when waitTimeout expires#25049
oscerd wants to merge 1 commit into
apache:camel-4.14.xfrom
oscerd:backport/CAMEL-24243-414

Conversation

@oscerd

@oscerd oscerd commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Backport of #25040 to camel-4.14.x.

When startQueryExecution's inner wait loop exits because waitTimeout
elapsed while the query was still QUEUED/RUNNING, no completion flag is
set, so shouldAttempt() returned true and the outer loop resubmitted the
same SQL as a brand-new Athena query — orphaning (and continuing to bill) the
running one. The fix makes shouldAttempt() treat wait-timeout expiry as
terminal, 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()); Athena2QueryHelperTest passes 24/24.

No upgrade-guide entry — bug fix, no user-visible configuration change.


Claude Code on behalf of oscerd

…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)
@oscerd
oscerd requested a review from davsclaus July 23, 2026 08:42
@oscerd oscerd added this to the 4.14.9 milestone Jul 23, 2026
@oscerd oscerd added the bug Something isn't working label Jul 23, 2026
@oscerd
oscerd requested review from gnodet and orpiske July 23, 2026 08:42

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 when attempts==0 (no query submitted yet) or when isRetry is 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants