Skip to content

Commit 89fdb1f

Browse files
Merge pull request #62279 from nextcloud/backport/61830/stable34
[stable34] fix(jobs): resolve portability issues with background job cleanup
2 parents f00c9c7 + 254b39e commit 89fdb1f

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

core/BackgroundJobs/CleanupBackgroundJobsJob.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ private function reapCrashedJobs(): void {
4747
if ($job->serverId !== $currentServerId) {
4848
continue;
4949
}
50-
$output = [];
51-
$result = 0;
52-
exec('ps -p ' . escapeshellarg((string)$job->pid) . ' -o cmd', $output, $result);
53-
if (count($output) === 1 && current($output) === 'CMD' && $result === 1) {
54-
// Process doesn't exists anymore
50+
$processExists = posix_kill($job->pid, 0) || posix_get_last_error() === 1 /* EPERM */;
51+
if (!$processExists) {
52+
// Process doesn't exist anymore
5553
$maxDuration = (new DateTimeImmutable())->diff($job->startedAt);
5654
$maxDuration
5755
= ($maxDuration->days * 24 * 60 * 60 * 1000)

lib/private/BackgroundJob/JobRuns.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public function finished(int|string $runId, int $duration, int $memoryPeakUsage,
6363

6464
public function deleteBefore(int $timestamp): int {
6565
$beforeSnowflake = $this->snowflakeGenerator->minForTimeId($timestamp);
66-
$beforeSnowflake = '91480652934574081';
6766
$qb = $this->connection->getQueryBuilder();
6867
$result = $qb
6968
->delete(self::TABLE)

0 commit comments

Comments
 (0)