scylladb / scylladb/alternator-client-java

Make LazyQueryPlan generate retry nodes on demand

Open
#141 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
0
Forks
7
Avg merge
21h 23m
Merged PRs (30d)
9

Description

Problem

LazyQueryPlan is intended to be lazy in the sense that routing should select the first node for the request, then only generate additional nodes if the SDK retries and asks for another target.

Today the implementation is only lazy until first access. ensureInitialized() snapshots and builds the full remaining plan when hasNext() or next() is first called. In seeded/key-affinity mode this can call drainSeeded(...), which computes the entire deterministic order up front even though most requests only use the first node.

Why this matters

For the common successful request path, the client should avoid doing work needed only for retries. This is especially relevant for key-affinity plans, where we only need the first active node initially; the rest of the deterministic sequence is only needed after a failure/retry.

Desired behavior

  • Create the request plan in beforeExecution as today.
  • On first routing attempt, compute only the first target node.
  • If that attempt fails and the SDK retries, compute the next target then.
  • Keep existing no-duplicate behavior across retries.
  • Keep seeded/key-affinity ordering compatible with the existing Go-compatible GoRand pick-and-remove sequence.
  • Preserve the current key-affinity behavior where the deterministic ring is based on all discovered scoped nodes and inactive nodes are skipped.

Notes

This likely means LazyQueryPlan should keep a mutable candidate set and a PRNG/cursor, but not materialize the full ordered retry list in ensureInitialized(). hasNext() may need at most a one-node lookahead because the AWS SDK calls it before next(), but it should not drain the full plan.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing LazyQueryPlan through beforeExecution(), ensureInitialized(), hasNext(), next(), and drainSeeded(...), then inspect how GoRand selects scoped active nodes. The change is complete when the first target is computed alone, retries generate one subsequent target at a time, no duplicates remain, and seeded/key-affinity ordering stays compatible.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.