Bug #90653 Allow closing ResultSet without draining connection in streaming mode
Submitted: 26 Apr 2018 18:35 Modified: 27 Apr 2018 9:49
Reporter: David Phillips Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any
Tags: jdbc

[26 Apr 2018 18:35] David Phillips
Description:
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();
statement.unwrap(com.mysql.cj.jdbc.JdbcStatement.class).enableStreamingResults();
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.

Thanks,
Chiranjeevi.
[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.