Bug #61189 2014: Commands out of sync; you can't run this command now
Submitted: 16 May 2011 17:34 Modified: 28 Jun 2011 21:29
Reporter: Sakthikumar B Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0 OS:Linux
Assigned to: CPU Architecture:Any
Tags: error 2014

[16 May 2011 17:34] Sakthikumar B
Description:
I'm getting 2014: Commands out of sync; you can't run this command now error when I try to insert some records to table. But its not stable, its working sometime and not sometime. Below are the details for reference,
Engine: myisam
Structure: CREATE TABLE IF NOT EXISTS `user_product` (
  `Sess` int(10) unsigned NOT NULL,
  `User` int(10) unsigned NOT NULL,
  `Product` bigint(20) unsigned NOT NULL,
  PRIMARY KEY  (`Sess`,`User`,`Product`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Query used: Insert ignore into empower_user_records (`Sess`,`User`,`Product`) values ('28','5','280051305564584758')
Error Returned: 2014: Commands out of sync; you can't run this command now

Note: When I get the above issue, the next 2 or 3 SQLs after this SQL getting the same error

How to repeat:
Its not stable, its working fine sometimes and not sometimes. I getting the error when fire the SQL 
Insert ignore into empower_user_records (`Sess`,`User`,`Product`) values ('28','5','280051305564584758')
[16 May 2011 17:35] Valeriy Kravchuk
What exact version of server, 5.0.x, do you use? What client software is used to execute the queries?
[16 May 2011 17:36] Sakthikumar B
Sorry, was wrong in the mentioned SQL, the table name in the SQL is 'user_products'
[16 May 2011 17:38] Sakthikumar B
the Server and Client version of MySQL is 5.0.82sp1
[16 May 2011 17:52] MySQL Verification Team
Try 5.0.92 and comment the results.

http://dev.mysql.com/downloads/mysql/5.0.html

Thanks.
[16 May 2011 18:10] Sakthikumar B
Hi Miguel,
Thank you for the alternate. Can you give me more information about this issue to convince my client to upgrade to the latest version of MySQL.
[19 May 2011 8:33] MySQL Verification Team
this is probably a bug in the application.. please examine:
http://dev.mysql.com/doc/refman/5.0/en/commands-out-of-sync.html
[19 May 2011 12:22] Sakthikumar B
Hi, thank you for the comments.
I found the cause of the issue in my application and fixed the same. Here are the details for your reference.
Actually I was calling the mysqli->multi_query() method before executing the mentioned query that produced error. It was suggested to free the result after executing the multi_query call and it is explained in http://php.net/manual/en/mysqli.multi-query.php
But the suggested methods to free the result didn't worked for me. So I closed the mysql connection after executed the multi_query and then created a new connection to continue executing the other queries.
This way I got this working.
[28 Jun 2011 21:29] MySQL Verification Team
Closing according last comment.