aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2023-12-20 14:16:16 +0100
committerJulien Veyssier <julien-nc@posteo.net>2024-05-02 16:43:41 +0200
commit993398b88a2dbb148b008b25abba3f6761dd0668 (patch)
tree7638719a964f1da4b3189ab60241cb21c17fa550 /core
parenta3d8632fbe5e255a30343c1950d9ec8a1849f5af (diff)
downloadnextcloud-server-993398b88a2dbb148b008b25abba3f6761dd0668.tar.gz
nextcloud-server-993398b88a2dbb148b008b25abba3f6761dd0668.zip
fix(bg-jobs): Remove interval bookkeeping
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'core')
-rw-r--r--core/Command/Background/JobWorker.php37
1 files changed, 1 insertions, 36 deletions
diff --git a/core/Command/Background/JobWorker.php b/core/Command/Background/JobWorker.php
index c0122e84694..aa991c96137 100644
--- a/core/Command/Background/JobWorker.php
+++ b/core/Command/Background/JobWorker.php
@@ -71,37 +71,21 @@ class JobWorker extends JobBase {
return 1;
}
- $interval = (int)($input->getOption('interval') ?? 5);
-
while (true) {
// Handle canceling of the process
try {
$this->abortIfInterrupted();
} catch (InterruptedException $e) {
- $output->writeln('<comment>Cleaning up before quitting. Press Ctrl-C again to kill, but this may have unexpected side effects.</comment>');
- $this->unlockExecuted();
$output->writeln('<info>Background job worker stopped</info>');
break;
}
$this->printSummary($input, $output);
- // Unlock jobs that should be executed again after the interval
- // Alternative could be to set last_checked to interval in the future to avoid the extra locks
- foreach ($this->executedJobs as $id => $time) {
- if ($time <= time() - $interval) {
- unset($this->executedJobs[$id]);
- $job = $this->jobList->getById($id);
- if ($job !== null) {
- $this->jobList->unlockJob($job);
- }
- }
- }
-
usleep(50000);
$job = $this->jobList->getNext(false, $jobClass);
if (!$job) {
- if ($input->getOption('once') === true || $interval === 0) {
+ if ($input->getOption('once') === true) {
break;
}
@@ -111,12 +95,6 @@ class JobWorker extends JobBase {
continue;
}
-
- if (isset($this->executedJobs[$job->getId()]) && ($this->executedJobs[$job->getId()] + $interval > time())) {
- $output->writeln("<comment>Job already executed within timeframe " . get_class($job) . " " . $job->getId() . '</comment>', OutputInterface::VERBOSITY_VERBOSE);
- continue;
- }
-
$output->writeln("Running job " . get_class($job) . " with ID " . $job->getId());
if ($output->isVerbose()) {
@@ -131,15 +109,12 @@ class JobWorker extends JobBase {
$this->jobList->setLastJob($job);
$this->jobList->unlockJob($job);
- $this->executedJobs[$job->getId()] = time();
if ($input->getOption('once') === true) {
break;
}
}
- $this->unlockExecuted();
-
return 0;
}
@@ -155,14 +130,4 @@ class JobWorker extends JobBase {
}
$this->writeTableInOutputFormat($input, $output, $counts);
}
-
- private function unlockExecuted() {
- foreach ($this->executedJobs as $id => $time) {
- unset($this->executedJobs[$id]);
- $job = $this->jobList->getById($id);
- if ($job !== null) {
- $this->jobList->unlockJob($job);
- }
- }
- }
}