function PdoSessionHandler::beginTransaction
Helper method to begin a transaction.
Since SQLite does not support row level locks, we have to acquire a reserved lock on the database immediately. Because of https://bugs.php.net/42766 we have to create such a transaction manually which also means we cannot use PDO::commit or PDO::rollback or PDO::inTransaction for SQLite.
Also MySQLs default isolation, REPEATABLE READ, causes deadlock for different sessions due to https://percona.com/blog/2013/12/12/one-more-innodb-gap-lock-to-avoid/ . So we change it to READ COMMITTED.
2 calls to PdoSessionHandler::beginTransaction()
- PdoSessionHandler::doRead in vendor/
symfony/ http-foundation/ Session/ Storage/ Handler/ PdoSessionHandler.php - Reads the session data in respect to the different locking strategies.
- PdoSessionHandler::getSelectSql in vendor/
symfony/ http-foundation/ Session/ Storage/ Handler/ PdoSessionHandler.php - Return a locking or nonlocking SQL query to read session information.
File
-
vendor/
symfony/ http-foundation/ Session/ Storage/ Handler/ PdoSessionHandler.php, line 555
Class
- PdoSessionHandler
- Session handler using a PDO connection to read and write data.
Namespace
Symfony\Component\HttpFoundation\Session\Storage\HandlerCode
private function beginTransaction() : void {
if (!$this->inTransaction) {
if ('sqlite' === $this->driver) {
$this->pdo
->exec('BEGIN IMMEDIATE TRANSACTION');
}
else {
if ('mysql' === $this->driver) {
$this->pdo
->exec('SET TRANSACTION ISOLATION LEVEL READ COMMITTED');
}
$this->pdo
->beginTransaction();
}
$this->inTransaction = true;
}
}