From 6f2739182460762725404126e3e538567d248148 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 8 Aug 2017 17:32:46 +0200 Subject: [PATCH] Close the transaction after 200 updates so it doesn't take too long Signed-off-by: Joas Schilling --- .../Repair/NC13/RepairInvalidPaths.php | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/private/Repair/NC13/RepairInvalidPaths.php b/lib/private/Repair/NC13/RepairInvalidPaths.php index 29a0e1ed157ca..4866fb4569b66 100644 --- a/lib/private/Repair/NC13/RepairInvalidPaths.php +++ b/lib/private/Repair/NC13/RepairInvalidPaths.php @@ -29,7 +29,7 @@ use OCP\Migration\IRepairStep; class RepairInvalidPaths implements IRepairStep { - const MAX_ROWS = 1000; + const MAX_ROWS = 200; /** @var IDBConnection */ private $connection; @@ -52,7 +52,7 @@ public function getName() { } /** - * @return \Generator + * @return array[] * @suppress SqlInjectionChecker */ private function getInvalidEntries() { @@ -75,14 +75,11 @@ private function getInvalidEntries() { ->where($builder->expr()->neq('f.path', $computedPath)) ->setMaxResults(self::MAX_ROWS); - do { - $result = $builder->execute(); - $rows = $result->fetchAll(); - foreach ($rows as $row) { - yield $row; - } - $result->closeCursor(); - } while (count($rows) > 0); + $result = $builder->execute(); + $rows = $result->fetchAll(); + $result->closeCursor(); + + return $rows; } private function getId($storage, $path) { @@ -176,9 +173,13 @@ public function run(IOutput $output) { $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); // was added to 12.0.0.30 and 13.0.0.1 if (version_compare($versionFromBeforeUpdate, '12.0.0.30', '<') || version_compare($versionFromBeforeUpdate, '13.0.0.0', '==')) { - $count = $this->repair(); + $totalCount = 0; + do { + $count = $this->repair(); + $totalCount += $count; + } while ($count === self::MAX_ROWS); - $output->info('Repaired ' . $count . ' paths'); + $output->info('Repaired ' . $totalCount . ' paths'); } } }