mochengqian opened a new pull request, #972:
URL: https://github.com/apache/dubbo-go-pixiu/pull/972

   ## Summary
   
   Closes #969.
   
   `nextStableEndpointID` (`pkg/server/cluster_manager.go`) and 
`uniqueSnapshotEndpointID` (`pkg/cluster/cluster.go`) were **byte-for-byte 
identical** implementations of the endpoint-ID collision-suffix algorithm, kept 
in sync only by convention. Since the endpoint ID is the runtime 
health/cooldown key, a future edit to one and not the other would silently 
assign **different** IDs to the same endpoint — splitting its health/cooldown 
state across a snapshot rebuild.
   
   This PR lifts the algorithm into a single shared helper and routes both 
paths through it, so they can never drift.
   
   ## Changes
   
   - Add `model.StableUniqueEndpointID(clusterName, endpoint, taken)` in 
`pkg/model/cluster.go`, next to `GenerateEndpointID` (which both call sites 
already use).
   - Remove `nextStableEndpointID` from `pkg/server`; repoint its three call 
sites (`assembleClusterEndpoints` ×2, `resolveSetEndpointSlotByHash`) to the 
shared helper.
   - Remove `uniqueSnapshotEndpointID` from `pkg/cluster`; repoint 
`newEndpointSnapshot` to the shared helper, and drop the now-unused `fmt` 
import.
   - Add `TestEndpointIDAssemblyAndSnapshotRebuildAgree`: feeds the same 
duplicate-ID config independently through config assembly and snapshot rebuild 
and asserts identical ID sequences — locking the two paths together. Covers 
both the explicit-duplicate-ID branch (`foo` / `foo-2`) and the anonymous 
identical-hash branch (`generated-<hash>` / `generated-<hash>-2`).
   
   Pure consolidation — no behavior change. The dedup *semantics* 
(suffix-vs-replace, hard-fail on duplicates) are out of scope, per #969 (that's 
#949's discussion).
   
   ## Test plan
   
   - [x] `go test ./pkg/model/... ./pkg/server/... ./pkg/cluster/...` passes 
(existing dedup tests in `pkg/server` and `pkg/cluster` unchanged).
   - [x] New `TestEndpointIDAssemblyAndSnapshotRebuildAgree` passes (both 
subtests).
   - [x] `go build ./...` clean.
   - [x] `gofmt -l` clean; `go vet` clean.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to