Make sure system.peers and peers_v2 match cluster metadata #4630
Open
minal-kyada wants to merge 1 commit intoapache:trunkfrom
Open
Make sure system.peers and peers_v2 match cluster metadata #4630minal-kyada wants to merge 1 commit intoapache:trunkfrom
minal-kyada wants to merge 1 commit intoapache:trunkfrom
Conversation
ifesdjeen
reviewed
Feb 25, 2026
|
|
||
| public static void validateAndRepair(ClusterMetadata metadata) | ||
| { | ||
| if (metadata != null) |
Contributor
There was a problem hiding this comment.
we should probably throw if it's null;
also, a small nit: I wouldn't nest entire method within if's brackets, i would early-exit on unmatched condition, and unindent the rest of the method.
ifesdjeen
reviewed
Feb 25, 2026
| private static Set<InetAddressAndPort> getPeersV2Entries() | ||
| { | ||
| Set<InetAddressAndPort> entries = new HashSet<>(); | ||
| String query = String.format("SELECT peer, peer_port FROM %s.%s", SchemaConstants.SYSTEM_KEYSPACE_NAME, PEERS_V2); |
Contributor
There was a problem hiding this comment.
Don't we want to validate all fields of the table? In updateLegacyPeerTable, we're updating more than just these two fields:
QueryProcessor.executeInternal(String.format(peers_v2_query, SYSTEM_KEYSPACE_NAME, PEERS_V2),
addresses.broadcastAddress.getAddress(), addresses.broadcastAddress.getPort(),
addresses.broadcastAddress.getAddress(), addresses.broadcastAddress.getPort(),
addresses.nativeAddress.getAddress(), addresses.nativeAddress.getPort(),
location.datacenter, location.rack,
nodeId.toUUID(),
next.directory.version(nodeId).cassandraVersion.toString(),
next.schema.getVersion(),
tokens);
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.
Description:
system.peersandsystem.peers_v2can drift out of sync withClusterMetadata, causing clients who use older C* version and tools that read these legacy tables to observe incorrect cluster topology.Adds
SystemPeersValidatorwhich reconciles both peer tables against ClusterMetadata on startup- removing stale entries for nodes no longer in the cluster and repairing missing entries for joined nodes. Also exposes this as a JMX operation viaStorageServiceMBeanso operators can trigger it on demand without restarting.Quick diagram of what the patch is about:

patch by @minal-kyada; reviewed by @ifesdjeen @krummas for CASSANDRA-21187