Skip to content

cowHostList uses outdated logic for host uniqueness #1757

@dkropachev

Description

@dkropachev

Please answer these questions before submitting your issue. Thanks!

What version of Cassandra are you using?

any

What version of Gocql are you using?

v1.6.0

What version of Go are you using?

1.22

What did you do?

My cluster is hidden behind proxy, all nodes are mapped to one address, but different ports.
For this purpose i have use custom AddressTranslator that maps broadcase_address of nodes nodes to host+port of the proxy.

It works great, but unfortunately if one node goes down I begin experiencing queries returning ErrNoConnections.
Source of the problem is the following, when nodes are being added to the roundRobinHostPolicy:
https://github.com/gocql/gocql/blob/6d279ed01c1069d14420584f3f7d5bc1794cf804/policies.go#L331-L333

It uses cowHostList.add to do the job, which does deduplication via HostInfo.Equal:
https://github.com/gocql/gocql/blob/6d279ed01c1069d14420584f3f7d5bc1794cf804/policies.go#L50-L60

Which relies on h.ConnectAddress().Equal(host.ConnectAddress()):
https://github.com/gocql/gocql/blob/6d279ed01c1069d14420584f3f7d5bc1794cf804/host_source.go#L135-L142

As result I end-up with only one node in the roundRobinHostPolicy.hosts pool and if this node is one that does not work, then I get ErrNoConnections after first retry.

What did you expect to see?

Everything works as supposed to

What did you see instead?

ErrNoConnections

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions