Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close the transaction after 200 updates so it doesn't take too long #6034

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 13 additions & 12 deletions lib/private/Repair/NC13/RepairInvalidPaths.php
Expand Up @@ -29,7 +29,7 @@
use OCP\Migration\IRepairStep;

class RepairInvalidPaths implements IRepairStep {
const MAX_ROWS = 1000;
const MAX_ROWS = 200;

/** @var IDBConnection */
private $connection;
Expand All @@ -52,7 +52,7 @@ public function getName() {
}

/**
* @return \Generator
* @return array[]
* @suppress SqlInjectionChecker
*/
private function getInvalidEntries() {
Expand All @@ -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) {
Expand Down Expand Up @@ -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');
}
}
}