sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Started transaction may not be rollback or commit

Open tisonkun opened this issue 7 months ago • 1 comments

I have found these related issues/pull requests

NO.

Description

https://github.com/launchbadge/sqlx/blob/bab1b022bd56a64f9a08b46b36b97c5cff19d77e/sqlx-core/src/transaction.rs#L105-L113

Although we have a Rollback defuse inside TransactionManager::begin e.g. for PG implementation, if the (future) drop happens between TransactionManager::begin and constructing the transaction struct, it will cause "there is already a transaction in progress" later.

Reproduction steps

As described above

SQLx version

0.8.6

Enabled SQLx features

pg

Database server and version

pg

Operating system

unrelated

Rust version

nightly

tisonkun avatar May 26 '25 04:05 tisonkun

I'm trying to manage this transaction state outside, but was blocked because transaction_depth and queue_simple_query is internal state. Even if I can manage transaction_depth by myself, without queue_simple_query I cannot queue a rollback query without waiting on it.

tisonkun avatar May 26 '25 04:05 tisonkun