New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySQL operation failed: Unknown prepared statement handler (${#}) given to mysqld_stmt_execute #805
Comments
|
interesting, never seen anything like this. "prepared statement handler" is just integer, it's local to connection and usually starts with When later you do if you think you can possibly reproduce this, can you add node-mysql2/lib/commands/execute.js Line 42 in 224c74d
This might indicate there is a bug in a way we cache statement id, but could be something else |
|
Thanks for the info @sidorares. I found it strange myself that this occurred, especially after the service was running fine at load for a month. I'll see if I can get something into place to debug if the issue occurs again. |
|
I have been getting the same error on my app. The error occurs when script is called multiple times in a short period of time. I think module is using a cached statement even though the statement was closed. I would appreciate it if I could get a work-around. Will it be more appropriate to not close the statement? This is a simplified version of the code // A list of rows to be inserted into table
var data = [
{col1: "val1", col2: "val2"},
{col1: "val3", col2: "val4"}
];
var stmnt, conn; // Statement and connection variables to be used in this function
// Get a connection from Pool
Pool.getConnection( function( errCon, connection ){
// Interupt the script if error occurs
if( errCon ){
finalize( errCon );
return;
}
conn = connection;
// Prepare statement
connection.prepare(
"INSERT into table( col1, col2 ) VALUES ( ?, ? ) ",
function( err, statement ){
// Interupt the script if error occurs
if( err ){
finalize( err );
return;
}
stmnt = statement;
// Insert data into DB table
data.forEach( row, index ){
statement.execute([ row.col1, row.col2 ], (errIn, result) => finalize( errIn, index ) )
}
}
)
}),
function finalize( err, index ){
if( err instanceof Error){
stmnt && stmnt.close(); // Close the prepared statement if it was set
conn && conn.release(); // Release the connection if it was created
console.log( err );
res.send("an error occured");
return;
}
if( data.length === index + 1 ){
stmnt && stmnt.close(); // Close the prepared statement if it was set
conn && conn.release(); // Release the connection if it was created
res.send("success")
}
} |
|
@dekyfin are you getting errors with your code? With manual |
Actually it does appear that manual In the case of a manual Replication: Solution:
|
|
Because the issue not yet resolved, I found only one way to workaround: use connection.unprepare() |
|
TL;DR for anyone facing the same issue: |
I have a service that has been running in production for a month with no issues. Last evening, the service failed after all queries using
.executewere throwing this error. Restarting the service resolved the issue.Let me know if I can provide more information.
The text was updated successfully, but these errors were encountered: