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


##########
topology.go:
##########
@@ -381,14 +381,20 @@ func (n *networkTopology) replicaMap(tokenRing 
*tokenRing) tokenRingReplicas {
        }
 
        dcsWithReplicas := 0
-       for _, dc := range n.dcs {
-               if dc > 0 {
+       for dc, rf := range n.dcs {
+               // We should count only DCs that driver is aware of and have a 
replication factor > 0
+               if _, knownDc := dcRacks[dc]; knownDc && rf > 0 {
                        dcsWithReplicas++
                }
        }
 
        if dcsWithReplicas == len(dcRacks) && len(replicaRing) != len(tokens) {
-               panic(fmt.Sprintf("token map different size to token ring: got 
%d expected %d", len(replicaRing), len(tokens)))
+               // Fallback to empty replica map if we have all the DCs with 
replicas but no replicas in the ring.
+               logger.Warning("Not enough replicas in the ring for the 
strategy key. Falling back to empty replica map.",

Review Comment:
   Hmm having this as a warning that will be repeatedly logged is not great 
because this is essentially a shortcoming of the driver (the driver should be 
able to compute replicas regardless of whether the user filters a host or not). 
   
   I propose two things:
   1 - create a ticket to implement a way for the driver to have access to all 
host metadata even if the application has a hostfilter in place
   2 - until that ticket is addressed we keep this log message but we either 
make sure to log it only once (per session?) or we change the log level to 
debug after the first time it is logged



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