This repository was archived by the owner on Jul 22, 2026. It is now read-only.
Fix cluster subsetting silent failure when peer URIs are IPv6 (SI-52492) - #1169
Merged
Merged
Conversation
ZKDeterministicSubsettingMetadataProvider compared the host's FQDN identity against URI.getHost()-form peer cluster URIs. When the d2 client materializes peer URIs in IPv6 form (typical with -Djava.net.preferIPv6Addresses=true, default-on across most LinkedIn services), the FQDN never matches the "[ipv6]" form returned by URI.getHost() on JDK 17, so instanceId = -1 and the subsetter fell back to the full host set. The failure was silent because the no-match branch logged at DEBUG. Resolve a Set<String> of candidate identities (FQDN, IPv4, bracketed and unbracketed IPv6, scope ids preserved) at construction via an injectable AddressResolver and match peer URIs with Set.contains. Bump the no-match log to WARN with a once-per-outage guard that re-arms on a successful match so flapping clusters don't spam the log. Public constructor signatures are preserved so consumers (notably container's D2ClientFactory) need no changes. Companion fix to grpc-infra PR #5819. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Inet6Address.getHostAddress() always returns the RFC 4291 fully-expanded
form ("2a04:f547:43:e66a:0:0:0:1a95"), but URI.getHost() returns
whatever was literally in the URI string — could be expanded or
compressed ("[2a04:f547:43:e66a::1a95]"). Java has no public API to
produce the compressed (RFC 5952) form, so if d2 ever materializes a
peer URI in compressed IPv6 the candidate set's expanded form silently
fails to match and the subsetter falls back to all hosts.
Add a private static canonicalizeIpv6IfApplicable that round-trips any
string containing ':' through InetAddress.getByName().getHostAddress().
FQDNs and IPv4 literals short-circuit on the colon check so no DNS work
happens on the hot path. Run both the local-side computeIdentities (so
the candidate set is in canonical form by construction) and the peer-
side getSubsettingMetadata lookup (so peer URI hosts get the same
treatment) through it; this keeps the two sides in lockstep even for
edge cases like IPv4-mapped IPv6 (::ffff:a.b.c.d), which getByName
auto-converts to Inet4Address — brackets are dropped in that case so a
canonicalized peer URI matches a local Inet4Address candidate.
Mirrors the same fix in grpc-infra PR #5819 (per psanglik's review on
that PR and the shared HostIdentities extraction that followed). Companion
to SI-52492.
7/7 ZKDeterministicSubsettingMetadataProviderTest cases pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
shivamgupta1
approved these changes
Jun 9, 2026
shivamgupta1
reviewed
Jun 9, 2026
|
|
||
| synchronized (_lock) | ||
| { | ||
| if (uriItem.getVersion() != _peerClusterVersion) |
Contributor
There was a problem hiding this comment.
The DNS resolution might be expensive but it only runs when there's a change to the cluster's version.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
ZKDeterministicSubsettingMetadataProvidercompared the host's FQDN identity againstURI.getHost()-form peer cluster URIs. When the d2 client materializes peer URIs in IPv6 form (typical with-Djava.net.preferIPv6Addresses=true,default-on across most LinkedIn services), the FQDN never matches the
[ipv6]form returned byURI.getHost()on JDK 17, soinstanceId = -1and the subsetter fell back to the full host set. The failure was silent because the no-matchbranch logged at DEBUG.
Set<String>of candidate identities (FQDN, IPv4, bracketed and unbracketed IPv6, scope ids preserved) at construction via an injectableAddressResolver, and match peer URIs withSet.containsinstead ofindexOf._warnedIdentityNotFoundguard that re-arms on a successful match so flapping clusters don't spam the log.D2ClientFactory) need no changes.Testing Done
testCandidateIdentities_includesFqdnIpv4AndIpv6,testCandidateIdentities_dnsFailure_fallsBackToFqdn,testCandidateIdentities_keepsIpv6ScopeId(usesInet6Address.getByAddressfor cross-OS portability),testGetSubsettingMetadata_matchesViaIpv6,testGetSubsettingMetadata_noMatch_warnsOnceThenReArmsOnRecovery.testGetSubsettingMetadata(FQDN match path) still passes../gradlew :d2:test --tests com.linkedin.d2.balancer.subsetting.ZKDeterministicSubsettingMetadataProviderTest(JDK 11, Gradle 6.9.4).RelativeLoadBalancerStrategy.<svc>-https-LoadBalancerStrategy.TotalHostsCountto drop from full cluster size to ~_minClusterSubsetSizefor clusters with_enableClusterSubsetting=true.