joao-r-reis commented on code in PR #1926:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1926#discussion_r2835375820


##########
policies.go:
##########
@@ -455,35 +457,57 @@ func (t *tokenAwareHostPolicy) IsLocal(host *HostInfo) 
bool {
 }
 
 func (t *tokenAwareHostPolicy) KeyspaceChanged(update KeyspaceUpdateEvent) {
-       t.mu.Lock()
-       defer t.mu.Unlock()
-       meta := t.getMetadataForUpdate()
-       t.updateReplicas(meta, update.Keyspace)
-       t.metadata.Store(meta)
+       if update.Change != KeyspaceDropped {
+               t.updateReplicas(update.Keyspace)
+       }
 }
 
-// updateReplicas updates replicas in clusterMeta.
-// It must be called with t.mu mutex locked.
+// updateReplicas updates replicas in clusterMeta for keyspace schema changes.
 // meta must not be nil and it's replicas field will be updated.
-func (t *tokenAwareHostPolicy) updateReplicas(meta *clusterMeta, keyspace 
string) {
-       newReplicas := make(map[string]tokenRingReplicas, len(meta.replicas))
-
+func (t *tokenAwareHostPolicy) updateReplicas(keyspace string) {

Review Comment:
   That's a fair point, how about we call the `updateAllReplicas` method (with 
the internal interface) when it's the first refresh? That would be the best of 
both worlds I think. Either we check session.initialized() or we just store a 
simple boolean flag in the refresh debouncer



-- 
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