From 3bdd7701297fa0958dddf11e69668dfafe2fa990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 13 Apr 2023 12:53:40 +0200 Subject: [PATCH] fix: Check for wrapped retriable exceptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/private/DB/Exceptions/DbalException.php | 5 +++++ lib/private/Files/Cache/Propagator.php | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/private/DB/Exceptions/DbalException.php b/lib/private/DB/Exceptions/DbalException.php index f9610c5bf2597..2b860a50ff36b 100644 --- a/lib/private/DB/Exceptions/DbalException.php +++ b/lib/private/DB/Exceptions/DbalException.php @@ -37,6 +37,7 @@ use Doctrine\DBAL\Exception\InvalidFieldNameException; use Doctrine\DBAL\Exception\NonUniqueFieldNameException; use Doctrine\DBAL\Exception\NotNullConstraintViolationException; +use Doctrine\DBAL\Exception\RetryableException; use Doctrine\DBAL\Exception\ServerException; use Doctrine\DBAL\Exception\SyntaxErrorException; use Doctrine\DBAL\Exception\UniqueConstraintViolationException; @@ -74,6 +75,10 @@ public static function wrap(\Doctrine\DBAL\Exception $original, string $message ); } + public function isRetryable(): bool { + return $this->original instanceof RetryableException; + } + public function getReason(): ?int { /** * Constraint errors diff --git a/lib/private/Files/Cache/Propagator.php b/lib/private/Files/Cache/Propagator.php index 4bf88a6084353..70fc238d9bed3 100644 --- a/lib/private/Files/Cache/Propagator.php +++ b/lib/private/Files/Cache/Propagator.php @@ -24,7 +24,7 @@ namespace OC\Files\Cache; -use Doctrine\DBAL\Exception\RetryableException; +use OC\DB\Exceptions\DbalException; use OC\Files\Storage\Wrapper\Encryption; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Cache\IPropagator; @@ -136,7 +136,11 @@ public function propagateChange($internalPath, $time, $sizeDifference = 0) { try { $builder->executeStatement(); break; - } catch (RetryableException $e) { + } catch (DbalException $e) { + if (!$e->isRetryable()) { + throw $e; + } + /** @var LoggerInterface $loggerInterface */ $loggerInterface = \OCP\Server::get(LoggerInterface::class); $loggerInterface->warning('Retrying propagation query after retryable exception.', [ 'exception' => $e ]);