-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An increasing number of WAITING state threads in JDBC driver #14176
Comments
thanks for providing the version! Can you please also make sure the problem is reproducible with the latest JDBC driver (396) too? |
I was able to reproduce this locally with @Test(timeOut = 60_000)
public void test()
throws Exception
{
int rowsToRead = TrinoResultSet.MAX_QUEUED_ROWS /* TrinoResultSet.AsyncIterator.MAX_QUEUED_ROWS */ + 5;
/*try (Connection connection = createConnection())*/ {
for (int i = 0; i < 30; i++) {
try (Connection connection = createConnection(); Statement statement = connection.createStatement()) {
boolean hasResultSet = statement.execute(format(
"SELECT * FROM UNNEST(sequence(0, %s)) CROSS JOIN UNNEST(sequence(0, %s))",
1000,
IntMath.divide(rowsToRead, 1000, UP)));
assertThat(hasResultSet).as("hasResultSet").isTrue();
Thread.sleep(1000); // let the AsyncIterator queue to fill up
}
}
}
System.out.println();
Thread.getAllStackTraces().keySet().stream()
.map(Thread::getName)
.filter(name -> name.toLowerCase(Locale.ROOT).contains("jdbc"))
.forEach(System.out::println);
} and it seems #13775 fixes the problem |
Indeed, it seems #13775 fixes the problem. The solution is similar to what I thought
|
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
version: presto-jdbc:329
jdk version: 1.8.0_261
MAX_QUEUED_ROWS
is declared inAsyncIterator
, which means that asynchronous threads namedPresto JDBC worker-%d
will be blocked when the amount of data is greater thanMAX_QUEUED_ROWS
.When a user submit a SQL query and the amount of data is larger than
MAX_QUEUED_ROWS
, the queue will be full. If the user callclose()
without getting the data out from the queue,we will find an increasing number of WAITING state threads over time.The code to close the query is shown below.
We notice that the
close
method eventually calls thefuture.cancel (true)
method, the source code ofcancel
inCompletableFuture
is shown below.We notice the parameter
mayInterruptIfRunning
has no effect in this implementation because interrupts are not used to control processing, so the threads namedPresto JDBC worker-%d
will be blocked forever. And in the latest version, the code has not changed much about it.Please correct me if i‘m wrong :)
The text was updated successfully, but these errors were encountered: