Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/private/DB/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Exception as DriverException;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Exception\ConnectionLost;
Expand Down Expand Up @@ -854,7 +855,14 @@ public function beginTransaction() {

#[\Override]
public function commit() {
$result = parent::commit();
try {
$result = parent::commit();
} catch (DriverException $e) {
// DBAL converts driver exceptions for queries, but not for COMMIT. Without
// this, a deadlock or a Galera certification failure raised at commit time
// escapes as a raw PDOException that no caller recognises as retryable.
throw $this->getDriver()->getExceptionConverter()->convert($e, null);
}
if ($this->getTransactionNestingLevel() === 0) {
$timeTook = microtime(true) - $this->transactionActiveSince;
$this->transactionBacktrace = null;
Expand Down
7 changes: 5 additions & 2 deletions lib/private/Files/Cache/Propagator.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ public function propagateChange(string $internalPath, int $time, int $sizeDiffer
}
break;
} catch (DbalException $e) {
if ($this->connection->getDatabaseProvider() !== IDBConnection::PLATFORM_SQLITE) {
// a failed commit already ended the transaction, so only roll back an open one
if ($this->connection->inTransaction()) {
$this->connection->rollBack();
}
if (!$e->isRetryable()) {
Expand Down Expand Up @@ -292,7 +293,9 @@ public function commitBatch(): void {

$this->connection->commit();
} catch (\Exception $e) {
$this->connection->rollback();
if ($this->connection->inTransaction()) {
$this->connection->rollback();
}
throw $e;
}
}
Expand Down
Loading