Skip to content

[Bug]: Transient connection error on worker fails all subsequent work items in CassandraIO read #39780

Closed

Description

@sharan-malyala

What happened?

In CassandraIO, when a worker fails to connect to Cassandra database while processing a work item, it throws an exception (like NoHostAvailableException) [1] and the work item fails. However, it was observed that all the subsequent work items ran on the same worker fail immediately with an IllegalStateException [2] without even attempting to connect to the database.

If a failed work item attempts all its leases on same worker, the entire job is failing due to a transient connectivity issue.

[1] - Initial Exception

	at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:270)  
	at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:109)  
	at com.datastax.driver.core.Cluster$Manager.negotiateProtocolVersionAndConnect(Cluster.java:1813)  
	at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1726)  
	at com.datastax.driver.core.Cluster.init(Cluster.java:214)  
	at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:387)  
	at com.datastax.driver.core.Cluster.connect(Cluster.java:338)  
	at org.apache.beam.sdk.io.cassandra.ConnectionManager.lambda$getSession$3(ConnectionManager.java:78)  
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)  
	at org.apache.beam.sdk.io.cassandra.ConnectionManager.getSession(ConnectionManager.java:76)```

[2] - Subsequent Exceptions (on same worker)
```java.lang.IllegalStateException: Can't use this cluster instance because it encountered an error in its initialization  
	at com.datastax.driver.core.Cluster.checkNotClosed(Cluster.java:650)  
	at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:386)  
	at com.datastax.driver.core.Cluster.connect(Cluster.java:338)  
	at org.apache.beam.sdk.io.cassandra.ConnectionManager.lambda$getSession$3(ConnectionManager.java:78)  
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)  
	at org.apache.beam.sdk.io.cassandra.ConnectionManager.getSession(ConnectionManager.java:76)```


### Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

### Issue Components

- [ ] Component: Python SDK
- [ ] Component: Java SDK
- [ ] Component: Go SDK
- [ ] Component: Typescript SDK
- [ ] Component: IO connector
- [ ] Component: Beam YAML
- [ ] Component: Beam examples
- [ ] Component: Beam playground
- [ ] Component: Beam katas
- [ ] Component: Website
- [ ] Component: Infrastructure
- [ ] Component: Spark Runner
- [ ] Component: Flink Runner
- [ ] Component: Prism Runner
- [ ] Component: Twister2 Runner
- [ ] Component: Hazelcast Jet Runner
- [ ] Component: Google Cloud Dataflow Runner

Activity

  1. sharan-malyala commented on Aug 17, 2026

    @sharan-malyala
    ContributorAuthor

    .take-issue

  2. sharan-malyala commented on Aug 17, 2026

    @sharan-malyala
    ContributorAuthor

    Triage :

    Ref - https://github.com/apache/beam/blob/master/sdks/java/io/cassandra/src/main/java/org/apache/beam/sdk/io/cassandra/ConnectionManager.java

    • The cluster object is created during the first attempt by the worker and cached in a Map within ConnectionManager.(line 63)
    • When getSession fails on an attempt (due to any transient issue on Cassandra), the broken Cluster object remains in the cache.
    • If any other work item runs on the same worker, it fetches this cached cluster object. The Datastax driver checks it via checkNotClosed() and immediately fails it with an IllegalStateException because of the previous initialization failure.
    • Because the broken connection is never evicted from the cache, a single transient failure permanently poisons the worker.

    Proposed solution :

    • Check if the cached Cluster object is closed/broken before attempting to use it.
    • If it is broken, remove it from the map and compute a fresh one.

    I will send a PR soon with the proposed change.

  3. sharan-malyala commented on Aug 17, 2026

    @sharan-malyala
    ContributorAuthor
  4. added this to the 2.77.0 Release milestone on Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions