Skip to content

fix: improve POST retry tests and document idempotency assumption#159

Merged
yuokada merged 3 commits into
masterfrom
retry-post-request
Jun 8, 2026
Merged

fix: improve POST retry tests and document idempotency assumption#159
yuokada merged 3 commits into
masterfrom
retry-post-request

Conversation

@yuokada

@yuokada yuokada commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #157 ("Add retry to POST /v1/statement") addressing review findings discovered after merge.

  • Add a comment in post_query_request! documenting that retrying Faraday::TimeoutError/ConnectionFailed on POST can submit duplicate queries, and explaining the load-balancer assumption that makes it intentional
  • Fix misleading test name: "retries POST on Timeout::Error" → "retries POST on Faraday::TimeoutError" (the code rescues Faraday::TimeoutError, not Timeout::Error directly)
  • Parameterize the retryable status test to cover all three values in RETRYABLE_STATUSES: 502, 503, and 504 (only 503 was tested)
  • Add test for retry_timeout exhaustion on POST — verifies TrinoHttpError(408) is raised when retries run out

Test plan

  • bundle exec rspec spec/statement_client_spec.rb — all 47 examples pass
  • bundle exec standardrb lib/trino/client/statement_client.rb spec/statement_client_spec.rb — no offenses

🤖 Generated with Claude Code

@yuokada yuokada requested a review from a team as a code owner June 8, 2026 02:47
- Add comment explaining duplicate-query risk when retrying POST on
  connection-level errors (Faraday::TimeoutError, ConnectionFailed)
- Fix test name: Timeout::Error -> Faraday::TimeoutError
- Parameterize retryable status test to cover 502, 503, and 504
- Add test for retry_timeout exhaustion raising TrinoHttpError(408)

Copilot AI 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.

Pull request overview

Follow-up to the earlier POST retry work, this PR clarifies the non-idempotency risk of retrying POST /v1/statement and strengthens the spec coverage around POST retry behaviors and retry-timeout exhaustion.

Changes:

  • Document the non-idempotent/duplicate-submission risk when retrying connection-level errors on POST /v1/statement.
  • Expand POST retry specs to cover all retryable HTTP statuses (502/503/504).
  • Add a spec for retry_timeout exhaustion on POST (expects a timeout-style TrinoHttpError).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/trino/client/statement_client.rb Adds an inline comment documenting the idempotency/duplicate-query assumption when retrying POST transport errors.
spec/statement_client_spec.rb Improves POST retry specs by parameterizing retryable statuses and adding a retry-timeout exhaustion expectation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/trino/client/statement_client.rb Outdated
Comment thread spec/statement_client_spec.rb Outdated
Comment thread spec/statement_client_spec.rb
yuokada and others added 2 commits June 8, 2026 12:12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@yuokada yuokada merged commit e64c2a9 into master Jun 8, 2026
9 checks passed
@yuokada yuokada deleted the retry-post-request branch June 8, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants