You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We encounter that DB::transactionLevel() shows an incorrect level after a DDL operation was done, which does commit implicitly. Consider this code snippet which is the current behaviour:
Log::debug(DB::transactionLevel()); // 0
DB::beginTransaction();
Log::debug(DB::transactionLevel()); // 1
DB::commit();
Log::debug(DB::transactionLevel()); // 0
DB::beginTransaction();
Log::debug(DB::transactionLevel()); // 1
// some DDL operation which closes the transaction
Log::debug(DB::transactionLevel()); // 1
This is problematic on different levels. First, getting the correct transaction level is important to be able to close all pending transactions. Second, due to a current change (see: #35380), DB::commit() and DB::rollback() both throw an exception if no active transaction is present. That means after beginTransaction and a DDL statement, this code:
if (DB::transactionLevel() > 0) {
DB::commit();
}
will fail.
Steps To Reproduce
DB::beginTransaction();
// do some DDL statement
if (DB::transactionLevel() > 0) {
DB::commit();
}
If necessary I could construct a minimal working example (but woudn't mind if it is not needed).
The text was updated successfully, but these errors were encountered:
Unfortunately we don't support this version anymore. Please check out our support policy on which versions we are currently supporting. Can you please try to upgrade to the latest version and see if your problem persists? If so, please open up a new issue and we'll help you out.
mrckzgl
changed the title
DB::transactionLevel() shows incorrect level, if DDL operation was done
Laravel 9: DB::transactionLevel() shows incorrect level, if DDL operation was done
Oct 19, 2023
Laravel Version
9.20.0
PHP Version
8.2.1
Database Driver & Version
10.10.2-MariaDB-1:10.10.2+maria~ubu2204
Description
We encounter that DB::transactionLevel() shows an incorrect level after a DDL operation was done, which does commit implicitly. Consider this code snippet which is the current behaviour:
This is problematic on different levels. First, getting the correct transaction level is important to be able to close all pending transactions. Second, due to a current change (see: #35380), DB::commit() and DB::rollback() both throw an exception if no active transaction is present. That means after beginTransaction and a DDL statement, this code:
will fail.
Steps To Reproduce
If necessary I could construct a minimal working example (but woudn't mind if it is not needed).
The text was updated successfully, but these errors were encountered: