Skip to content

fix(api-cache): wait as long as a refusing query server asks (#889) - #925

Merged
tkuhn merged 1 commit into
masterfrom
fix/889-retry-after
Nov 13, 2026
Merged

tkuhn merged 1 commit into
masterfrom
fix/889-retry-after

Conversation

@tkuhn

@tkuhn tkuhn commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Part of #889. Follow-up to #890, possible now that nanopub 1.96.0 (pinned in #924) reports a query server's refusal as QueryRefusedException with the server's Retry-After time.

Changes

  • Retry-After honoured: when the query servers refuse a query and name a time, ApiCache waits until then before the next attempt — never less than the backoff step for the failure count (10 s / 30 s / 1 min / 5 min), never more than 5 minutes.
  • No looping on refusals: QueryApiAccess.forcedGet hands a refusal to the caller instead of asking again for 30 seconds.

forcedGet still retries for up to 30 seconds on other failures (timeouts, unreachable); that is unchanged.

Testing

  • mvn test passes (1890 tests); three new tests in ApiCacheTest and QueryApiAccessTest.
  • End to end: a local instance with NANOPUB_QUERY_INSTANCES pointing at a proxy to the live query service that answers 503 with Retry-After: 45 for queries mentioning a marker IRI. Fresh visits to /explore?id=<marker> every 15 s: each of the page's five queries was sent once, logged "not trying it again for 44s", was not sent on the visits 15 s and 30 s later, and was sent once more after 45 s. The plain backoff would have retried after 10 s.
  • The live service also refused get-all-user-intros during startup (Retry-After: 4): one request, then the ordinary 10 s step, since that is the longer of the two.

🤖 Generated with Claude Code

A query server that refuses a query (503/429 with Retry-After) names the
time it will take the query again. nanopub-java 1.96.0 passes that on as
QueryRefusedException:

- ApiCache waits until that time before the next attempt, though never
  less than the backoff step for the failure count and never more than
  five minutes.
- QueryApiAccess.forcedGet hands a refusal to the caller instead of asking
  again for 30 seconds, which sent a refusing server about 15 requests per
  attempt.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@tkuhn
tkuhn merged commit 4a7b0e4 into master Nov 13, 2026
8 checks passed
@tkuhn
tkuhn deleted the fix/889-retry-after branch November 13, 2026 15:40
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 5.23.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant