Bug #41119 automatic reprepare of prepared statements fails sporadically after flush tables
Submitted: 29 Nov 2008 7:34 Modified: 26 May 2011 19:30
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.1.30, 5.1.52 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any
Tags: Com_stmt_reprepare

[29 Nov 2008 7:34] Shane Bester
Description:
According to http://dev.mysql.com/doc/refman/5.1/en/statement-repreparation.html
"Repreparation is automatic" after flush tables.  

This works in 99% of the cases, but there are some failures like this:

mysql_stmt_execute failed: Prepared statement needs to be re-prepared (1615)
host 0, thread 8 failed in prepared_query_execute for query: select * from `qa00` limit 5

How to repeat:
see attached .c testcase.
[29 Nov 2008 7:42] MySQL Verification Team
testcase.  errors happen about 10 times per 30000 queries.

Attachment: bug41119.c (text/plain), 11.39 KiB.

[29 Nov 2008 7:44] MySQL Verification Team
output of testcase on Solaris:

running initializations..
client version=50130
server version=50130
pre-generating 16777216 bytes of random data
about to spawn 10 threads
..........
completed spawning new database worker threads
testcase is now running, so watch for error output
queries: 000000952
queries: 000001948
<cut>
queries: 000018419
queries: 000019019
mysql_stmt_execute failed: Prepared statement needs to be re-prepared (1615)
queries: 000019580
queries: 000020153
queries: 000020715
mysql_stmt_execute failed: Prepared statement needs to be re-prepared (1615)
queries: 000021324
queries: 000021924
queries: 000022508
queries: 000023012
queries: 000023622
mysql_stmt_execute failed: Prepared statement needs to be re-prepared (1615)
queries: 000024229
queries: 000024847
[3 Dec 2008 14:31] Konstantin Osipov
Shane,
there are 3 attempts to reprepare a statement.
If you are constantly flushing tables, each attempt may fail.
This is an artificial example. We can increase the number of attempts.
At best it should be documented.
[14 Nov 2010 0:33] Valeriy Kravchuk
The fact that only 3 attempts of re-preparation are made is NOT documented in http://dev.mysql.com/doc/refman/5.1/en/statement-repreparation.html. Please, fix it.

See bug #42041 also (if this report will even be back at development side).
[26 May 2011 19:30] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.