Skip to content

CASSSIDECAR-495: Report each instance's own Sidecar instance id in th… - #380

Open
bianca-stanciu29 wants to merge 4 commits into
apache:trunkfrom
bianca-stanciu29:CASSSIDECAR-495
Open

bianca-stanciu29 wants to merge 4 commits into
apache:trunkfrom
bianca-stanciu29:CASSSIDECAR-495

Conversation

@bianca-stanciu29

@bianca-stanciu29 bianca-stanciu29 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Analytics needs the Sidecar instance ID associated with a target Cassandra node when constructing per-instance requests. A client-side hostname lookup cannot reliably supply this information when addresses differ or instances are accessed through a shared endpoint.

Solution

Add an optional sidecarInstanceId to ring entries and token-range replica metadata. The server resolves it from its local instance configuration using the node's address.

  • Populate the field for nodes managed by the responding Sidecar.
  • Leave it null for nodes that the responding Sidecar does not manage.
  • Preserve existing ring fields, replica-map keys, and read/write ranges.
  • Keep the previous public RingEntry and ReplicaMetadata constructors. They leave the ID null, so existing client-common callers keep working.

Clients can pass the reported ID as the instanceId query parameter to a Sidecar configured to manage that node.

Related client work: apache/cassandra-analytics#222 (CASSANALYTICS-177).

Scope and topology limitations

These IDs belong to the responding Sidecar's local configuration; they are not cluster-global routing identifiers.

When a Sidecar manages all relevant instances, it can report IDs for all of them. With one Sidecar per node, a response only reports the locally managed node's ID; other entries remain null.

This change does not select a load-balancer backend or rewrite destination addresses. A subsequent request must reach a Sidecar configured to recognize the supplied ID. Initial discovery through a load balancer may still require explicit contact-point routing configuration.

Testing

  • RingEntry and ReplicaMetadata: JSON round-trip, deserializing responses without the new field, and the previous constructors.
  • InstanceMetadataFetcher: lookup of managed and unmanaged addresses.
  • Handlers: both ring routes and the token-range-replicas route. Managed nodes get their ID, unmanaged nodes get null, and the rest of the response is unchanged.

Run locally on the branch merged with current trunk:

  • All checkstyle checks, RAT, and SpotBugs on the changed modules.
  • JDK 11: all unit tests in client-common, client and adapters-base.
  • JDK 17 (DTEST_JAR=dtest-5.0.7.jar): integration-test compilation, RingHandlerTest and InstanceMetadataFetcherTest.

Tests ran with -x checkEnvironment because the macOS multi-node loopback aliases are missing locally. The full server test suite, the integration tests, and an end-to-end load-balancer test have not been run.

JIRA: https://issues.apache.org/jira/browse/CASSSIDECAR-495

…e ring / token-range-replicas response

Enrich RingEntry and ReplicaMetadata with the id of the local Sidecar
instance managing each node/replica, resolved via
InstanceMetadataFetcher#sidecarInstanceId(host) in KeyspaceRingHandler
and TokenRangeReplicaMapHandler. Entries not managed by this Sidecar
retain a null id. This lets clients discover which instanceId to pass
for a given node/replica in a follow-up request, which matters most
when the client sits behind a load balancer and cannot otherwise
guarantee it reaches the Sidecar managing that node.
@yifan-c yifan-c changed the title [CASSSIDECAR-495] Report each instance's own Sidecar instance id in th… CASSSIDECAR-495: Report each instance's own Sidecar instance id in th… Oct 6, 2026
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