Open dkropachev opened 3 years ago
Problem goes from src/main/java/com/datastax/driver/core/HostConnectionPool.java:
We have 5 attributes that needs to be initialized before being used:
List<Connection>[] connections;
private AtomicInteger[] open;
@VisibleForTesting Set<Connection>[] trash;
private Queue<PendingBorrow>[] pendingBorrows;
private AtomicInteger[] scheduledForCreation;
But we initialize them only at HostConnectionPool.initAsyncWithConnection , which may not happen due to the exception escaping at HostConnectionPool.initAsync:
ListenableFuture<Void> initAsync(Connection reusedConnection) {
if (reusedConnection != null && reusedConnection.setOwner(this)) {
return initAsyncWithConnection(reusedConnection);
}
try {
return initAsyncWithConnection(manager.connectionFactory().open(this));
} catch (Exception e) {
phase.compareAndSet(Phase.INITIALIZING, Phase.INIT_FAILED);
SettableFuture<Void> future = SettableFuture.create();
future.setException(e);
return future;
}
}
So basically when initial connection fails we end up with perfectly uninitialized instance
Faced this issue once while playing with nosqlbench: