Copilot commented on code in PR #967:
URL: https://github.com/apache/dubbo-go-pixiu/pull/967#discussion_r3371162735
##########
pkg/server/cluster_manager.go:
##########
@@ -356,10 +356,18 @@ func (s *ClusterStore) AddCluster(c *model.ClusterConfig)
{
stopClusters([]*cluster.Cluster{s.replaceClusterRuntime(c.Name, c)})
}
-// prepareClusterConfig rebuilds endpoint defaults and hash from current
endpoints.
+// prepareClusterConfig rebuilds endpoint defaults from current endpoints and
+// invalidates the Config-level consistent hash. The hash is only read by the
+// legacy (non-snapshot) pick path and is rebuilt lazily there via
+// ClusterConfig.EnsureConsistentHash, so eagerly rebuilding it on every
+// AddCluster/UpdateCluster/SetEndpoint/DeleteEndpoint is dead work for the
+// common snapshot path (and expensive for large Maglev tables under
+// service-discovery churn). Setting it to nil here keeps the legacy path
+// correct after endpoint changes: the next legacy pick rebuilds from the
+// current endpoints instead of serving a stale ring.
func (s *ClusterStore) prepareClusterConfig(c *model.ClusterConfig) {
s.assembleClusterEndpoints(c)
- c.CreateConsistentHash()
+ c.ConsistentHash.Hash = nil
}
Review Comment:
prepareClusterConfig now clears c.ConsistentHash.Hash unconditionally.
Previously it called CreateConsistentHash(), which only overwrote the hash when
a ConsistentHashInitFunc exists for c.LbStr; any programmatically pre-populated
hash for an unregistered/custom policy would have been preserved, but will now
be lost. Consider only invalidating the hash for policies that actually have a
factory registered.
--
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]