Skip to content

feat(cli): connect to several addresses and follow the primary (chunkdb/chunkdb#155) - #60

Merged
eventvoid merged 4 commits into
mainfrom
feat/several-addresses
Nov 29, 2026
Merged

eventvoid merged 4 commits into
mainfrom
feat/several-addresses

Conversation

@eventvoid

Copy link
Copy Markdown
Member

Part of chunkdb/chunkdb#155 (Clients accept several addresses, find the current primary and reconnect after a failover).

Accept comma-separated URI endpoints and repeatable --endpoint options. The CLI checks the target table's serving state and uses bounded ordered discovery on connect and reconnect. It skips known recovery states and repeats inconclusive or ambiguous sweeps within the discovery budget. Node-local commands require a direct connection, and routed data statements check the table from the CQL prefix.

The shell reconnects on the new primary and requires ROLLBACK to clear an interrupted transaction before sending more statements. One-shot commands and transaction files preserve the failed statement's error and exit status. Table watches pass their last processed epoch and revision to the new primary. They report resync if the server cannot prove continuity, preserve TAKEOVER through setup, and reattach after a slot failure only when the primary address or table epoch changed. Replication watches explain any missing discovery grant.

Fake-server tests cover role and permission checks, recovering peers, admission refusals, discovery bounds, promotion during a sweep, persistent ambiguity, node-local command rejection, DELETE BLOCK routing, interrupted shell transactions, lost write and COMMIT replies, watch continuity, takeover, missing slots and replication gaps. URI and routing tests cover address parsing and allocation-free routing checks. These tests are pending CI.

This completes the CLI portion of the box. The Go and JavaScript clients have separate changes.

Accept ordered endpoint lists in connection URIs and flags. Resolve the serving primary with HELLO and table status before sending statements.

Rediscover after follower refusals and transport failures without replaying writes. Resume table watches from their last processed position and surface resync.

Keep interrupted shell transactions blocked until ROLLBACK. Route DELETE BLOCK by FROM, scan only the routing prefix and require a direct endpoint for node-local commands.

Skip peers in recovery and retry ambiguous observations or temporary admission limits within the discovery budget. Explain the discovery grants for replication watches, check for a changed primary after a slot failure and preserve TAKEOVER until the first attach attempt.
Replace the assertion that --table is unknown with coverage for the routing table, ordered endpoint flags, missing arguments and invalid ports.

The existing users test expects permission-denial output that predates the server's right and table metadata. The mismatch also applies to the single-address path on main.

Match discovery and slot-watch fixtures to the server's permission metadata and default recovery and missing-slot reason keys.
Decode stderr as one JSON object and check the error code, class and reason fields. A follower refusal includes its reason in both the summary and the server key map.
@eventvoid
eventvoid merged commit 2c92e40 into main Nov 29, 2026
5 checks passed
@eventvoid
eventvoid deleted the feat/several-addresses branch November 29, 2026 23:16
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.

1 participant