-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Panic at sqlx-core-0.5.1/src/mysql/io/buf.rs:25 #1078
Comments
changing if db_version != version {
return Err(api::Error::VersionConflict(db_version, version));
}; to if db_version != version {
drop(tx); // <-------- added line
return Err(api::Error::VersionConflict(db_version, version));
}; leads to the same panic. but changing it to: if db_version != version {
tx.rollback().await.map_err(|e| api::Error::ServerSideError(e.into()))?;
return Err(api::Error::VersionConflict(db_version, version));
}; works. So manually rollbacking the transaction at every failure code path can be a temporary workaround. |
Hello macro_rules! try_rollback {
($tx:expr,$result:expr) => {{
if let Err(err) = $result {
let _ = $tx.rollback().await; // you can handle this error if you like
return Err(err.into());
}
}};
} And here is how I use it: let mut tx = conn.begin().await?;
try_rollback!(tx, Database::my_function(&mut tx, id).await); |
Closed by #1439 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The function:
When there is a version conflict, I get this panic, I guess probably when the transaction is being rolled-back.
the code is available here: https://github.com/PaulGrandperrin/cachou/blob/crash_in_sqlx/server/src/db/sql.rs#L166
The text was updated successfully, but these errors were encountered: