Repository navigation
CASSANALYTICS-79: Make Token ranges calculation rack aware for spark.data.partitioner.CassandraRing - #149
Open
sklaha wants to merge 4 commits into
Open
CASSANALYTICS-79: Make Token ranges calculation rack aware for spark.data.partitioner.CassandraRing#149sklaha wants to merge 4 commits into
sklaha wants to merge 4 commits into
Conversation
yifan-c
reviewed
Jan 7, 2026
| return new long[]{h1, h2}; | ||
| } | ||
|
|
||
| protected static long invRShiftXor(long value, int shift) |
Contributor
There was a problem hiding this comment.
Why are those new methods added?
Comment on lines
+106
to
+118
| private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException | ||
| { | ||
| this.token = in.readUTF(); | ||
| this.node = in.readUTF(); | ||
| this.dataCenter = in.readUTF(); | ||
| } | ||
|
|
||
| private void writeObject(ObjectOutputStream out) throws IOException | ||
| { | ||
| out.writeUTF(token()); | ||
| out.writeUTF(nodeName()); | ||
| out.writeUTF(dataCenter()); | ||
| } |
Contributor
There was a problem hiding this comment.
Why adding the custom serialization code? The string fields should be serializable by default, and the readObject & writeObject methods are unnecessary.
Comment on lines
-37
to
+42
| private final String token; | ||
| private final String node; | ||
| private final String dataCenter; | ||
| private String token; | ||
| private String node; | ||
| private String dataCenter; |
Contributor
There was a problem hiding this comment.
Once readObject & writeObject are removed, the final modifiers can be restored.
Comment on lines
+77
to
78
| private transient RangeMap<BigInteger, List<CassandraInstance>> replicasForRanges; | ||
| private transient RangeMap<BigInteger, List<CassandraInstance>> replicas; |
Contributor
There was a problem hiding this comment.
It is confusing to have 2 maps and they actually point to the same object if I am not mistaken.
More importantly, it leads to different init code paths. The patch is to fix the broken token calculation, but why leaving it half-fixed? The CDC code patch still calls the original constructor, which means CDC is still broken.
Comment on lines
+152
to
+153
| //updateInternal(1, key, VALUE2); | ||
| //expectedValuesInNodes.put(1, VALUE2); |
mansikhara
pushed a commit
to mansikhara/cassandra-analytics
that referenced
this pull request
Nov 3, 2026
…ranges and replicas from Cassandra The bulk reader derived token ranges and replicas from node tokens and the replication factor, assuming racks are not in use. NetworkTopologyStrategy is rack aware, so with uneven racks the derived replicas can differ from Cassandra's and a read can return incomplete or stale data. CASSANALYTICS-197 took the ranges from Sidecar's token-range-replicas endpoint only for keyspaces with transient replicas, as the ring held one token per node. Take them from Cassandra for every keyspace. A node owning several tokens is represented once, carrying its lowest token, as the reported ranges say which ranges it replicates. deriveTokenRanges falls back to the local derivation, and is ignored for keyspaces with transient replicas; it replaces forceCassandraTokenRanges, which is now the default. An incomplete token-range-replicas response fails with a clear message. CDC had the same problem: SidecarCommitLogProvider chose which instances to list commit logs on from a ring derived with the maximal replication factor, so with uneven racks it could skip a replica holding mutations. It now takes the write replicas of every CDC-enabled keyspace from Sidecar, caches them for tokenRangeReplicasRefreshInterval or until the cluster changes, and falls back to the previous replicas, then to the derived ring, if Sidecar fails. SidecarCdcOptions.deriveTokenRanges keeps the previous behaviour. Adds a data-level integration test on a two-datacenter cluster with uneven racks, where a replica that only rack-aware placement includes holds the newest value, and a vnode variant of the multi-rack placement checks. Builds on the approach in apache#149.
mansikhara
pushed a commit
to mansikhara/cassandra-analytics
that referenced
this pull request
Nov 3, 2026
…ranges and replicas from Cassandra The bulk reader derived token ranges and replicas from node tokens and the replication factor, assuming racks are not in use. NetworkTopologyStrategy is rack aware, so with uneven racks the derived replicas can differ from Cassandra's and a read can return incomplete or stale data. CASSANALYTICS-197 took the ranges from Sidecar's token-range-replicas endpoint only for keyspaces with transient replicas, as the ring held one token per node. Take them from Cassandra for every keyspace. A node owning several tokens is represented once, carrying its lowest token, as the reported ranges say which ranges it replicates. deriveTokenRanges falls back to the local derivation, and is ignored for keyspaces with transient replicas; it replaces forceCassandraTokenRanges, which is now the default. An incomplete token-range-replicas response fails with a clear message. CDC had the same problem: SidecarCommitLogProvider chose which instances to list commit logs on from a ring derived with the maximal replication factor, so with uneven racks it could skip a replica holding mutations. It now takes the write replicas of every CDC-enabled keyspace from Sidecar, caches them for tokenRangeReplicasRefreshInterval or until the cluster changes, and falls back to the previous replicas, then to the derived ring, if Sidecar fails. SidecarCdcOptions.deriveTokenRanges keeps the previous behaviour. Adds a data-level integration test on a two-datacenter cluster with uneven racks, where a replica that only rack-aware placement includes holds the newest value, and a vnode variant of the multi-rack placement checks. Builds on the approach in apache#149.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes in the PR: