Skip to content

Commit

Permalink
Merge pull request #45559 from nextcloud/bug/noid/add-reason-lock-wai…
Browse files Browse the repository at this point in the history
…t-timeout

add mapping for lock wait timeout
  • Loading branch information
kesselb committed May 29, 2024
2 parents fca38e1 + 3fb0aa4 commit 75ce3b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/private/DB/Exceptions/DbalException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Doctrine\DBAL\Exception\InvalidFieldNameException;
use Doctrine\DBAL\Exception\LockWaitTimeoutException;
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
use Doctrine\DBAL\Exception\RetryableException;
Expand Down Expand Up @@ -82,6 +83,9 @@ public function getReason(): ?int {
/**
* Other server errors
*/
if ($this->original instanceof LockWaitTimeoutException) {
return parent::REASON_LOCK_WAIT_TIMEOUT;
}
if ($this->original instanceof DatabaseObjectExistsException) {
return parent::REASON_DATABASE_OBJECT_EXISTS;
}
Expand Down
7 changes: 7 additions & 0 deletions lib/public/DB/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ class Exception extends BaseException {
*/
public const REASON_UNIQUE_CONSTRAINT_VIOLATION = 14;

/**
* The lock wait timeout was exceeded
*
* @since 30.0.0
*/
public const REASON_LOCK_WAIT_TIMEOUT = 15;

/**
* @return int|null
* @psalm-return Exception::REASON_*
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/DB/Exception/DbalExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Doctrine\DBAL\Exception\InvalidFieldNameException;
use Doctrine\DBAL\Exception\LockWaitTimeoutException;
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
use Doctrine\DBAL\Exception\ServerException;
Expand Down Expand Up @@ -45,6 +46,7 @@ public function testDriverException(string $class, int $reason): void {

public function dataDriverException(): array {
return [
[LockWaitTimeoutException::class, DbalException::REASON_LOCK_WAIT_TIMEOUT],
[ForeignKeyConstraintViolationException::class, DbalException::REASON_FOREIGN_KEY_VIOLATION],
[NotNullConstraintViolationException::class, DbalException::REASON_NOT_NULL_CONSTRAINT_VIOLATION],
[UniqueConstraintViolationException::class, DbalException::REASON_UNIQUE_CONSTRAINT_VIOLATION],
Expand Down

0 comments on commit 75ce3b3

Please sign in to comment.