feat(CleanupRedis): improve stuck job cleanup logic by prioritizing reserved_at timestamp

This commit is contained in:
Andras Bacsai 2025-11-11 15:27:52 +01:00
parent 133d6a0349
commit 684a08bf75

View file

@ -379,10 +379,19 @@ private function cleanupStuckJobs($redis, string $prefix, bool $dryRun, bool $is
// Parse job payload to get job class and started time
$payloadData = json_decode($payload, true);
$jobClass = data_get($payloadData, 'displayName', 'Unknown');
$pushedAt = (int) data_get($data, 'pushed_at', 0);
// Prefer reserved_at (when job started processing), fallback to created_at
$reservedAt = (int) data_get($data, 'reserved_at', 0);
$createdAt = (int) data_get($data, 'created_at', 0);
$startTime = $reservedAt ?: $createdAt;
// If we can't determine when the job started, skip it
if (! $startTime) {
continue;
}
// Calculate how long the job has been processing
$processingTime = $now - $pushedAt;
$processingTime = $now - $startTime;
$shouldFail = false;
$reason = '';