Skip to content

Failed commit not properly rolled back #332

@Bixilon

Description

@Bixilon

Sometimes when committing a transaction (https://github.com/blackbeam/mysql_async/blob/master/src/queryable/transaction.rs#L179), it commit fails because of a mysql deadlock. When this happens you must explicitly rollback the changes, otherwise when creating a new transaction it will be nested.

This is checked in the code, but somehow it does not work and I could not find any tests in it.

I must wrap my code from

        trx.commit().await.map(|_| result).map_err(Into::into)

to

        match trx.commit().await {
            Ok(_) => {
                Ok(result)
            },
            Err(e) => {
                conn.query_drop("ROLLBACK;").await?;
                Err(e.into())
            }
        }

See stalwartlabs/stalwart#1271 for more details.

Can you please fix this?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions