Cluster.Connect() throws "ArgumentException 'The source argument contains duplicate keys.'"

Description

In some very rare cases, Cluster.Connect() throws NoHostAvailableException where every host connection attempt fails with ArgumentException 'The source argument contains duplicate keys.'.

Looking at the stack trace this is coming from the TokenMap constructor when a ConcurrentDictionary is initialized from an existing Dictionary.

When this happens, the only way to resolve the issue is to restart the application.

This was reported privately by a user and also by another user on the Apache Cassandra users mailing list: https://www.mail-archive.com/user@cassandra.apache.org/msg60772.html

Environment

None

Assignee

Unassigned

Reporter

Joao Reis

Labels

None

Reproduced in

3.12.0
3.14.0
3.16.0

PM Priority

None

Fix versions

External issue ID

None

Doc Impact

None

Reviewer

None

Pull Request

None

Epic Link

None

Sprint

Pull Requests

None

Size

None

Affects versions

Priority

Major
Configure