[ 
https://issues.apache.org/jira/browse/CASSGO-122?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bohdan Siryk updated CASSGO-122:
--------------------------------
    Description: 
There is a panic during session initialization when a multi-DC C* cluster has 2 
keyspaces, and one of them is not replicated to the DC the session connected to 
via HostFilter.

To reproduce setup C* multi-dc cluster *ccm create -v 5.0.8 gocql_test3 -n 3:3* 
and run the following code:
```
func main() { 
  // CREATE KEYSPACE IF NOT EXISTS ks1 WITH replication = \\{ 'class': 
'NetworkTopologyStrategy', 'datacenter1': 3 };
  // CREATE KEYSPACE IF NOT EXISTS ks2 WITH replication = \{ 'class': 
'NetworkTopologyStrategy', 'datacenter1': 3, 'datacenter2': 3 };
  const localDC = "dc1"
  const remoteDC = "dc2"
  cfg := gocql.NewCluster("127.0.0.4") 
  cfg.PoolConfig.HostSelectionPolicy = 
gocql.TokenAwareHostPolicy(gocql.RoundRobinHostPolicy()) 
  cfg.HostFilter = gocql.HostFilterFunc(func(host *gocql.HostInfo) bool { 
     return host.DataCenter() == remoteDC 
  }) 
  session, err := cfg.CreateSession() 
  if err != nil { 
    panic(err) 
  } 
  defer session.Close() 
  metadata, err := session.KeyspaceMetadata("ks1") 
  if err != nil { 
    panic(err) 
  }

  fmt.Println(toJSON(metadata))
}

func toJSON(data any) string { 
  json, err := json.Marshal(data) 
  if err != nil {
    panic(err) 
  }

  return string(json)
}

Originally raised: 
[https://github.com/apache/cassandra-gocql-driver/issues/1947]

  was:
There is a panic during session initialization when a multi-DC C* cluster has 2 
keyspaces, and one of them is not replicated to the DC the session connected to 
via HostFilter.

To reproduce setup C* multi-dc cluster *ccm create -v 5.0.8 gocql_test3 -n 3:3* 
and run the following code:
func main() {   // CREATE KEYSPACE IF NOT EXISTS ks1 WITH replication = \{ 
'class': 'NetworkTopologyStrategy', 'datacenter1': 3 };// CREATE KEYSPACE IF 
NOT EXISTS ks2 WITH replication = \{ 'class': 'NetworkTopologyStrategy', 
'datacenter1': 3, 'datacenter2': 3 };const localDC = "dc1"const remoteDC = 
"dc2"cfg := gocql.NewCluster("127.0.0.4")   cfg.PoolConfig.HostSelectionPolicy 
= gocql.TokenAwareHostPolicy(gocql.RoundRobinHostPolicy())   cfg.Timeout = 1 * 
time.Hourcfg.ConnectTimeout = 1 * time.Hourcfg.HostFilter = 
gocql.HostFilterFunc(func(host *gocql.HostInfo) bool {            return 
host.DataCenter() == remoteDC    })      session, err := cfg.CreateSession()    
 if err != nil {         panic(err)
        }       defer session.Close()   metadata, err := 
session.KeyspaceMetadata("ks1")        if err != nil {         panic(err)
        }       fmt.Println(toJSON(metadata))
}func toJSON(data any) string { json, err := json.Marshal(data) if err != nil { 
        panic(err)
        }       return string(json)
}

Originally raised: https://github.com/apache/cassandra-gocql-driver/issues/1947


> Panic when using a HostFilter and keyspace is not replicated to every DC
> ------------------------------------------------------------------------
>
>                 Key: CASSGO-122
>                 URL: https://issues.apache.org/jira/browse/CASSGO-122
>             Project: Apache Cassandra Go driver
>          Issue Type: Bug
>            Reporter: Bohdan Siryk
>            Priority: Normal
>
> There is a panic during session initialization when a multi-DC C* cluster has 
> 2 keyspaces, and one of them is not replicated to the DC the session 
> connected to via HostFilter.
> To reproduce setup C* multi-dc cluster *ccm create -v 5.0.8 gocql_test3 -n 
> 3:3* and run the following code:
> ```
> func main() { 
>   // CREATE KEYSPACE IF NOT EXISTS ks1 WITH replication = \\{ 'class': 
> 'NetworkTopologyStrategy', 'datacenter1': 3 };
>   // CREATE KEYSPACE IF NOT EXISTS ks2 WITH replication = \{ 'class': 
> 'NetworkTopologyStrategy', 'datacenter1': 3, 'datacenter2': 3 };
>   const localDC = "dc1"
>   const remoteDC = "dc2"
>   cfg := gocql.NewCluster("127.0.0.4") 
>   cfg.PoolConfig.HostSelectionPolicy = 
> gocql.TokenAwareHostPolicy(gocql.RoundRobinHostPolicy()) 
>   cfg.HostFilter = gocql.HostFilterFunc(func(host *gocql.HostInfo) bool { 
>      return host.DataCenter() == remoteDC 
>   }) 
>   session, err := cfg.CreateSession() 
>   if err != nil { 
>     panic(err) 
>   } 
>   defer session.Close() 
>   metadata, err := session.KeyspaceMetadata("ks1") 
>   if err != nil { 
>     panic(err) 
>   }
>   fmt.Println(toJSON(metadata))
> }
> func toJSON(data any) string { 
>   json, err := json.Marshal(data) 
>   if err != nil {
>     panic(err) 
>   }
>   return string(json)
> }
> Originally raised: 
> [https://github.com/apache/cassandra-gocql-driver/issues/1947]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to