From 684a08bf7503d7ef7f010d05203b820b8accd897 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Tue, 11 Nov 2025 15:27:52 +0100 Subject: [PATCH] feat(CleanupRedis): improve stuck job cleanup logic by prioritizing reserved_at timestamp --- app/Console/Commands/CleanupRedis.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/CleanupRedis.php b/app/Console/Commands/CleanupRedis.php index a5fdc33e0..04e7b7df5 100644 --- a/app/Console/Commands/CleanupRedis.php +++ b/app/Console/Commands/CleanupRedis.php @@ -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 = '';