-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The problem lies in the following code:
session.executeScanQuery(
yql, sdkParams, settings,
rs -> new ResultSetConverter(rs).stream(statement::readResult).forEach(spliterator::onNext)
).whenComplete(spliterator::onSupplierThreadComplete);
If the CompletableFuture<Status> completes before whenComplete(spliterator::onSupplierThreadComplete) is registered, then spliterator::onSupplierThreadComplete will be invoked on the main thread.
This method attempts to insert an element into an ArrayBlockingQueue<>(1). If the queue is not empty, it will lock itselft until the element is consumed. However, since the consumer (tryAdvance) runs on the same main thread, a deadlock occurs:
onSupplierThreadCompleteblocks, waiting for the queue to be drained.tryAdvancecannot proceed until onSupplierThreadComplete returns.
Eventually, onSupplierThreadComplete fails due to a timeout, and tryAdvance never receives the signal that data has ended — so it also fails.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working