Repository navigation
Prefer announce hostname when dialing cluster node on reconnect - #3333
meerasridharan-28 wants to merge 4 commits into
Conversation
350a7b7 to
075d560
Compare
075d560 to
eba62dd
Compare
eba62dd to
cc5731b
Compare
|
Thank you for digging into this — the scenario is nasty (SLOTS announcing hostnames while NODES reports unreachable companion pod IPs), the intent here is right, and the SNI/hostname angle genuinely matters for these deployments. The test that moves a slot to a hostname-announcing shard and checks the companion IP resolves to the same server is a good addition. That said, review turned up some structural concerns — the main one being that the fix appears to hold only on first discovery, with the underlying adoption mechanism unchanged. In rough order of importance:
I realize (1) is a bigger ask than a touch-up — it's a genuinely tricky corner of the codebase, and the fact that the aliasing subtleties surfaced at all is down to this PR putting a concrete scenario and tests on the table, which is valuable in itself. Happy to talk through the resolve-time approach on the PR or the linked issue if that helps. Thanks again for taking this on. |
|
@mgravell Thanks for the detailed feedback, I mainly tested scenario we reproduced, where a cluster shard is moved/ restarted with host-name based routing and this PR fix was working for that case. I see from your review that there are additional complex scenarios that current approach may not cover. I am still trying to understand al the scenarios you listed above. Since we need this fix fairly soon, would you be able to take on the structural changes you are suggesting? |
…alized, on every topology application The selection-branch approach is reverted: SelectIdentity and ResolveOrCreate return to 'any identity we already hold', and the preference moves into ApplyTopologyGenerationAsync, which already owns survivor choice, alias overwrite and duplicate merging. A node held by a companion address while SLOTS announces a hostname first is re-homed - a server is adopted at the hostname form (exactForm, so the repair does not resolve through the alias being repaired) and the companion server is retired through the existing merge machinery, which also re-points every alias. Running at topology application makes the preference hold however the companion server came to exist (a MOVED redirect, a NODES-only refresh, state from an earlier preference), not only on first discovery. Discovery also creates a SLOTS-listed node at its announced form in the first place, via an identity -> preferred-form map built in the loop that already visits every identity, so the common path never creates the companion server at all. Configured endpoints are exempt throughout: a user's explicit seed is never re-homed from under them. Tests: the seeded regression case returns (a slot map fed from SLOTS must resolve to servers we already hold); the single-seed discovery case stays, made deterministic with an explicit applied topology; and a new case covers re-homing a node already held by its address when the announced preference changes.
|
As discussed, I've taken on the structural rework and pushed it to this branch (a09a6a3) — your commit and tests stay as the foundation, and your scenario is still the thing the PR fixes. What moved, and why:
Tests: your single-seed discovery test stays (made deterministic with an explicit applied-topology pass), the original seeded regression test is restored alongside it, and there's a new case covering the durable half — a shard already held by its IP moving to its hostname when the announced preference changes. Full suite is green locally apart from a pre-existing environment flake unrelated to this area. Thanks again for the repro, the tests and the patience — the concrete scenario is what made the right fix findable. Please give it a try against your deployment: the behaviour you fixed should hold, and now also survive pod restarts and later topology refreshes. |
|
@mgravell Thanks for taking time to fix this PR. Really appreciate your help getting this issue addressed. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When
cluster-preferred-endpoint-type=hostname,CLUSTER SLOTScan announce shard hostnames whileCLUSTER NODESreports companion pod IPs. In deployments where those IPs are not reachable, selecting an IP endpoint can prevent the client from connecting to a shard after topology changes.This PR makes cluster discovery and slot routing prefer the endpoint form announced by
CLUSTER SLOTS. When that form is a hostname, the companion IP is treated as an alias rather than preferred as a separate dialable server. IP-preferred clusters continue to prefer IP endpoints, and the existingCLUSTER NODESbehavior is preserved when there is no usableCLUSTER SLOTStopology.Regression coverage checks endpoint preference for IP- and hostname-preferred topologies. It also uses a single configured seed, moves a slot to a hostname-announcing shard, and verifies the shard is discovered by hostname while its companion IP resolves to the same server.
Related: PR #3250
[ISSUE] (#3309 (comment))
Checklist