3296
MySQLERRORNotableSystem VariablesHIGH confidence
Variable cannot be set inside a transaction
Production Risk
Medium — the variable change is rejected and the transaction continues with old settings.
How to reproduce
trigger — this will error
trigger — this will error
START TRANSACTION; SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
expected output
ERROR 3296 (HY000): Variable 'transaction_isolation' cannot be set while a transaction is active.
Fix
Set before transaction
Set before transaction
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; START TRANSACTION;
Why this works
Setting the isolation level before the transaction begins works correctly.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3296 ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev