Skip to content

Commit

Permalink
fix: Check for wrapped retriable exceptions
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliushaertl authored and backportbot-nextcloud[bot] committed Jun 21, 2023
1 parent a7dc41f commit 72cb434
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/private/DB/Exceptions/DbalException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,6 +76,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
Expand Down
8 changes: 6 additions & 2 deletions lib/private/Files/Cache/Propagator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = \OC::$server->get(LoggerInterface::class);
$loggerInterface->warning('Retrying propagation query after retryable exception.', [ 'exception' => $e ]);
Expand Down

0 comments on commit 72cb434

Please sign in to comment.