Skip to content

Commit 6be7034

Browse files
dkropachevclaude
andcommitted
fix: prevent session hang when system.client_routes table is absent
Pre-load client routes during init() before topology discovery. When the routes cache is empty (table doesn't exist on older Scylla versions), buildNodeEndPoint falls back to DefaultEndPoint instead of creating ClientRoutesEndPoint that would fail to resolve, causing infinite connection retry loops and session builder hangs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 30d6c4b commit 6be7034

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

core/src/main/java/com/datastax/oss/driver/internal/core/metadata/ClientRoutesTopologyMonitor.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ public CompletionStage<Void> init() {
8989
context
9090
.getEventBus()
9191
.register(ControlConnectionReconnectEvent.class, this::onReconnectEvent);
92-
return super.init();
92+
// Pre-load client routes before topology discovery so that buildNodeEndPoint can decide
93+
// whether to use ClientRoutesEndPoint (routes available) or fall back to DefaultEndPoint
94+
// (table absent / empty — e.g. older Scylla versions without system.client_routes).
95+
return queryAndResolveRoutes(false).thenCompose(ignored -> super.init());
9396
}
9497

9598
/** Returns the {@link ClientRoutesConfig} this handler was built from. */
@@ -242,6 +245,12 @@ protected EndPoint buildNodeEndPoint(
242245
@NonNull AdminRow row,
243246
@Nullable InetSocketAddress broadcastRpcAddress,
244247
@NonNull EndPoint localEndPoint) {
248+
// If the routes cache is empty (e.g. system.client_routes does not exist on this server
249+
// version), fall back to the default endpoint resolution so that the session can still
250+
// function normally.
251+
if (resolvedRoutesCache.get().isEmpty()) {
252+
return super.buildNodeEndPoint(row, broadcastRpcAddress, localEndPoint);
253+
}
245254
UUID hostId = Objects.requireNonNull(row.getUuid("host_id"));
246255
InetAddress broadcastInetAddress = null;
247256
if (broadcastRpcAddress != null) {

0 commit comments

Comments
 (0)