mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
## Problem Scheduled tasks, backups, and auto-updates stopped working after 1-2 months with error: MaxAttemptsExceededException: App\Jobs\ScheduledJobManager has been attempted too many times. Root cause: ScheduledJobManager used WithoutOverlapping with only releaseAfter(60), causing locks without expiration (TTL=-1) that persisted indefinitely when jobs hung or processes crashed. ## Solution ### Part 1: Prevention (Future Locks) - Added expireAfter(60) to ScheduledJobManager middleware - Lock now auto-expires after 60 seconds (matches everyMinute schedule) - Changed from releaseAfter(60) to expireAfter(60)->dontRelease() - Follows Laravel best practices and matches other Coolify jobs ### Part 2: Recovery (Existing Locks) - Enhanced cleanup:redis command with --clear-locks flag - Scans Redis for stale locks (TTL=-1) and removes them - Called automatically during app:init on startup/upgrade - Provides immediate recovery for affected instances ## Changes - app/Jobs/ScheduledJobManager.php: Added expireAfter(60)->dontRelease() - app/Console/Commands/CleanupRedis.php: Added cleanupCacheLocks() method - app/Console/Commands/Init.php: Auto-clear locks on startup - tests/Unit/ScheduledJobManagerLockTest.php: Test to prevent regression - STALE_LOCK_FIX.md: Complete documentation ## Testing - Unit tests pass (2 tests, 8 assertions) - Code formatted with Pint - Matches pattern used by CleanupInstanceStuffsJob 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| Actions/User | ||
| Policies | ||
| Rules | ||
| ApplicationDeploymentEmptyEnvTest.php | ||
| ApplicationGitSecurityTest.php | ||
| ApplicationHealthcheckRemovalTest.php | ||
| ApplicationWatchPathsTest.php | ||
| BashEnvEscapingTest.php | ||
| CloudInitScriptValidationTest.php | ||
| DatalistComponentTest.php | ||
| DockerComposeLabelParsingTest.php | ||
| DockerImageAutoParseTest.php | ||
| DockerImageParserTest.php | ||
| GitLsRemoteParsingTest.php | ||
| GlobalSearchNewImageQuickActionTest.php | ||
| HetznerDeletionFailedNotificationTest.php | ||
| HetznerSshKeysTest.php | ||
| ParseDockerVolumeStringTest.php | ||
| PreSaveValidationTest.php | ||
| PrivateKeyStorageTest.php | ||
| ProxyCustomCommandsTest.php | ||
| ScheduledJobManagerLockTest.php | ||
| ServiceConfigurationRefreshTest.php | ||
| ServiceNameSecurityTest.php | ||
| ServiceParserImageUpdateTest.php | ||
| SshRetryMechanismTest.php | ||
| ValidateShellSafePathTest.php | ||
| ValidGitRepositoryUrlTest.php | ||
| ValidHostnameTest.php | ||
| VolumeArrayFormatSecurityTest.php | ||
| VolumeSecurityTest.php | ||
| WindowsPathVolumeTest.php | ||