{"record":{"id":"76ae7a1b9e2671a9","repo":"yiisoft/yii2","slug":"failed-to-set-isolation-level-transaction-was-ina","errorCode":null,"errorMessage":"Failed to set isolation level: transaction was inactive.","messagePattern":"Failed to set isolation level: transaction was inactive\\.","errorType":"exception","errorClass":"yii\\db\\Exception","httpStatus":null,"severity":"error","filePath":"framework/db/Transaction.php","lineNumber":235,"sourceCode":"        }\n    }\n\n    /**\n     * Sets the transaction isolation level for this transaction.\n     *\n     * This method can be used to set the isolation level while the transaction is already active.\n     * However this is not supported by all DBMS so you might rather specify the isolation level directly\n     * when calling [[begin()]].\n     * @param string $level The transaction isolation level to use for this transaction.\n     * This can be one of [[READ_UNCOMMITTED]], [[READ_COMMITTED]], [[REPEATABLE_READ]] and [[SERIALIZABLE]] but\n     * also a string containing DBMS specific syntax to be used after `SET TRANSACTION ISOLATION LEVEL`.\n     * @throws Exception if the transaction is not active\n     * @see https://en.wikipedia.org/wiki/Isolation_%28database_systems%29#Isolation_levels\n     */\n    public function setIsolationLevel($level)\n    {\n        if (!$this->getIsActive()) {\n            throw new Exception('Failed to set isolation level: transaction was inactive.');\n        }\n        Yii::debug('Setting transaction isolation level to ' . $level, __METHOD__);\n        $this->db->getSchema()->setTransactionIsolationLevel($level);\n    }\n\n    /**\n     * @return int The current nesting level of the transaction.\n     * @since 2.0.8\n     */\n    public function getLevel()\n    {\n        return $this->_level;\n    }\n}\n","sourceCodeStart":217,"sourceCodeEnd":250,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/db/Transaction.php#L217-L250","documentation":"Error \"Failed to set isolation level: transaction was inactive.\" thrown in yiisoft/yii2.","triggerScenarios":"Thrown at framework/db/Transaction.php:235 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}