-
-
Notifications
You must be signed in to change notification settings - Fork 300
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: Driver error: `Transactions couldn't be nested. #1271
Comments
So I figured out what is going on: Due to multiple stalwart servers running on the same database, they do some operation (fts or data storing or anything else) and somehow the commit fails (due to a deadlock or something else) and then the transaction is retried after some time. The problem is, that it was never rolled back (see https://stackoverflow.com/questions/38133260/is-it-necessary-to-rollback-if-commit-fails). This is just a problem because the same connection is reused. Instead of trx.commit().await.map(|_| result).map_err(Into::into) something like this is better: match trx.commit().await {
Ok(_) => {
Ok(result)
},
Err(e) => {
trx.rollback().await?;
Err(e.into())
}
} (this does not work, because commit is by value and rollback afterwards is not allowed). This actually makes me thing if that is the right approach at all. The database is preventing us, because values might have changed. Wouldn't it make more sense to reapply the changes and try to merge them somehow? Still hard. |
See stalwartlabs#1271 for more details
The mySQL driver should automatically rollback transactions that are dropped, it that is not the case there might be a bug in the mySQL rust crate. |
It is kinda hard to properly rollback on drop, since Rust doesn't have AsyncDrop yet |
What I meant to say is that they are supposed to rollback on errors, in this case the library is taking ownership of the transaction when For every other error Stalwart will always roll back the transaction as long as it has access to the |
What happened?
Hi there,
I am sometimes noticing the following lines in the logs (and an error on the client side):
This is probably caused, because mysql (I am using it as data, lookup and directory storage) does not support (see https://stackoverflow.com/questions/1306869/are-nested-transactions-allowed-in-mysql).
I suspect you retry some action that failed before, but without rolling back (or commiting) properly. I don't know where exactly.
How can we reproduce the problem?
Hard to say, happens farily rarely.
Version
v0.11.x
What database are you using?
SQLite
What blob storage are you using?
mySQL
Where is your directory located?
SQL
What operating system are you using?
Linux
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: