Bug #47321 FLUSH TABLE causes mysql_fetch_row to fail
Submitted: 15 Sep 2009 12:05 Modified: 15 Oct 2009 14:48
Reporter: Einav Itamar Email Updates:
Status: No Feedback Impact on me:
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:5.0.51a OS:Linux
Assigned to: CPU Architecture:Any
Tags: flush table, mysql_fetch_row, mysql_use_result

[15 Sep 2009 12:05] Einav Itamar
When using mysql_use_result() and mysql_fetch_row() in order to read a result set, running 'flush table X' on the server on the same time causes the connection to get lost. mysql_fetch_row returns null, and mysql_error returns "Lost connection to MySQL server during query".
the state is not recoverable by reconnecting. The scan must be restarted

How to repeat:
Use the C API to scan the table using mysql_use_result and mysql_fetch_row.
Place a breakpoint in the middle of the loop.

From the shell, execute "FLUSH TABLE X" when X is the scanned table from above.

continue the execution from the debugger.
mysql_fetch_row will return null, and the error is not recoverable by reconnecting.

Suggested fix:
Save the state of the scan on the client side, and restore it when necessary.
Another option: make sure that flush table does restores the state of scans.
[15 Sep 2009 14:48] Sveta Smirnova
Thank you for the report.

But version 5.0.51 is old and many bugs were fixed since. Please try current version 5.0.85 and if problem still exists provide full error log file.
[15 Oct 2009 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".