Skip to content

Panic when using a HostFilter and keyspace is not replicated to every DC #1947

@max-melentyev

Description

@max-melentyev

Hey, we see this panic

panic: token map different size to token ring: got 0 expected 120
goroutine 415 [running]:
github.com/apache/cassandra-gocql-driver/v2.(*networkTopology).replicaMap(0x25c6b9516810, 0x25c6b96629c0)
	/go/pkg/mod/github.com/apache/cassandra-gocql-driver/v2@v2.1.0/topology.go:391 +0x1274
github.com/apache/cassandra-gocql-driver/v2.(*tokenAwareHostPolicy).updateAllReplicas(0x25c6b8c53ac8?, 0x25c6b87a1de0, 0xd326c0?)
	/go/pkg/mod/github.com/apache/cassandra-gocql-driver/v2@v2.1.0/policies.go:559 +0x112
github.com/apache/cassandra-gocql-driver/v2.(*tokenAwareHostPolicy).schemaRefreshed(0x25c6b8b95800, 0x25c6b8782dc0)
	/go/pkg/mod/github.com/apache/cassandra-gocql-driver/v2@v2.1.0/policies.go:543 +0x90
github.com/apache/cassandra-gocql-driver/v2.refreshSchemas(0x25c6b8694f08)
	/go/pkg/mod/github.com/apache/cassandra-gocql-driver/v2@v2.1.0/metadata.go:865 +0xd71
github.com/apache/cassandra-gocql-driver/v2.NewSession.func1()
	/go/pkg/mod/github.com/apache/cassandra-gocql-driver/v2@v2.1.0/session.go:174 +0x17
github.com/apache/cassandra-gocql-driver/v2.(*refreshDebouncer).flusher(0x25c6b85b3590)
	/go/pkg/mod/github.com/apache/cassandra-gocql-driver/v2@v2.1.0/host_source.go:1009 +0x17d
created by github.com/apache/cassandra-gocql-driver/v2.newRefreshDebouncer in goroutine 414
	/go/pkg/mod/github.com/apache/cassandra-gocql-driver/v2@v2.1.0/host_source.go:945 +0x145

It happens when session is configured with host filter to connect only to hosts in a local dc:

cluster.HostFilter = gocql.HostFilterFunc(func(host *gocql.HostInfo) bool {
	return host.DataCenter() == cfg.LocalDC
})

And there is a keyspace that is not replicated to all DCs:

CREATE KEYSPACE ks1 WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': '3'}  AND durable_writes = true;
CREATE KEYSPACE ks2 WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': '3', 'dc2': '3'}  AND durable_writes = true;

UPD. It happens for clients with LocalDC: dc2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions