Bug #90653 Allow closing ResultSet without draining connection in streaming mode
Submitted: 26 Apr 2018 18:35 Modified: 23 Jul 2021 11:20
Reporter: David Phillips Email Updates:
Status: Won't fix Impact on me:
Category:Connector / J Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any
Tags: jdbc

[26 Apr 2018 18:35] David Phillips
When using streaming mode, closing the ResultSet will result in all of the remaining rows being read. This happens in ResultsetRowsStreaming (see the comment "drain the rest of the records"). This can result in a huge amount of network transfer and wasted server resources.

How to repeat:
Connection connection = ...;
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("SELECT ... FROM huge_table");
rs.close(); // this will read all the rows

Suggested fix:
Add some way to disable this "feature".
[27 Apr 2018 9:49] Chiranjeevi Battula
Hello David Phillips,

Thank you for the bug report.
Verified based on internal discussion with dev's.

[18 May 2018 20:00] Mark Matthews
The only way to implement this would be a server protocol change. If the rows aren't read off of the open connection, further statements cannot be sent to the server (it will respond with an error). The only option to not "drain" the results - is to close the connection.
[23 Jul 2021 11:20] Alexander Soklakov
Posted by developer:
It's not feasible to fix this issue without changing the MySQL protocol.