Commit graph

32 commits

Author SHA1 Message Date
Andras Bacsai
ed979f42ef Fix SSH multiplexing contention for concurrent scheduled tasks (#6736)
When multiple scheduled tasks or database backups run concurrently on
the same server, they compete for the same SSH multiplexed connection
socket, causing race conditions and SSH exit code 255 errors.

This fix adds a `disableMultiplexing` parameter to bypass SSH
multiplexing for jobs that may run concurrently:

- Add `disableMultiplexing` param to `generateSshCommand()`
- Add `disableMultiplexing` param to `instant_remote_process()`
- Update `ScheduledTaskJob` to use `disableMultiplexing: true`
- Update `DatabaseBackupJob` to use `disableMultiplexing: true`
- Add debug logging to track execution without multiplexing
- Add unit tests for the new parameter

Each backup and scheduled task now gets an isolated SSH connection,
preventing contention on the shared multiplexed socket.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 09:54:30 +01:00
Andras Bacsai
d3eaae1aea Increase scheduled task timeout limit to 36000 seconds
Extended the maximum allowed timeout for scheduled tasks from 3600 to 36000 seconds (10 hours). Also passes the configured timeout to instant_remote_process() so the SSH command respects the timeout setting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 20:04:55 +01:00
Andras Bacsai
644df223dc fix(ScheduledTaskJob): make server property nullable and update logging to handle null values 2025-11-11 15:38:55 +01:00
Andras Bacsai
64c7d301ce feat(DatabaseBackupJob, ScheduledTaskJob): enforce minimum timeout and add execution ID for timeout handling 2025-11-11 12:07:39 +01:00
Andras Bacsai
1580c0d3ad
Update app/Jobs/ScheduledTaskJob.php
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-11-10 11:41:50 +01:00
Andras Bacsai
b22e79caec feat(jobs): improve scheduled tasks with retry logic and queue cleanup
- Add retry configuration to CoolifyTask (3 tries, 600s timeout)
- Add retry configuration to ScheduledTaskJob (3 tries, configurable timeout)
- Add retry configuration to DatabaseBackupJob (2 tries)
- Implement exponential backoff for all jobs (30s, 60s, 120s intervals)
- Add failed() handlers with comprehensive error logging to scheduled-errors channel
- Add execution tracking: started_at, retry_count, duration (decimal), error_details
- Add configurable timeout field to scheduled tasks (60-3600s, default 300s)
- Update UI to include timeout configuration in task creation/editing forms
- Increase ScheduledJobManager lock expiration from 60s to 90s for high-load environments
- Implement safe queue cleanup with restart vs runtime modes
  - Restart mode: aggressive cleanup (marks all processing jobs as failed)
  - Runtime mode: conservative cleanup (only marks jobs >12h as failed, skips deployments)
- Add cleanup:redis --restart flag for system startup
- Integrate cleanup into Dev.php init() for development environment
- Increase scheduled-errors log retention from 7 to 14 days
- Create comprehensive test suite (unit and feature tests)
- Add TESTING_GUIDE.md with manual testing instructions

Fixes issues with jobs failing after single attempt and "attempted too many times" errors
2025-11-10 11:11:18 +01:00
Andras Bacsai
b1a2938f84 fix(ScheduledTaskJob): replace generic Exception with NonReportableException for better error handling 2025-09-09 09:30:44 +02:00
peaklabs-dev
30f36f96db
fix: use finished_at for the end time instead of created_at 2025-01-16 15:12:57 +01:00
Andras Bacsai
1fe4dd722b Revert "rector: arrrrr"
This reverts commit 16c0cd10d8.
2025-01-07 15:31:43 +01:00
Andras Bacsai
16c0cd10d8 rector: arrrrr 2025-01-07 14:52:08 +01:00
peaklabs-dev
99eea783ae
feat: scheduled task success and failure notifications 2024-12-10 14:45:47 +01:00
peaklabs-dev
060c8262bc
chore: remove comment out code 2024-12-09 12:48:54 +01:00
Andras Bacsai
7dc65dfd79 fix: make sure important jobs/actions are running on high prio queue 2024-11-22 11:16:01 +01:00
Andras Bacsai
376a2341af refactor scheduled task job (and related stuffs) 2024-11-07 11:09:38 +01:00
Lucas Michot
1ec224fde1 Inline many variables. 2024-10-31 18:20:11 +01:00
Lucas Michot
8e1444eaa7 Get rid of many useless blank lines 2024-10-31 17:44:01 +01:00
Lucas Michot
601f1a4717 Always prefer stricter string comparisons. 2024-10-31 15:23:19 +01:00
Andras Bacsai
57d8930f9e chore: Update cleanup command to use Redis instead of queue 2024-09-23 23:48:12 +02:00
Andras Bacsai
b570ccd7d3 format 2024-09-23 19:51:31 +02:00
ayntk-ai
48734e53d0
formatting 2024-08-16 21:22:06 +02:00
ayntk-ai
dab5f0fe09
add logic 2024-08-16 16:01:41 +02:00
ayntk-ai
1892ce4e12
Feat: cron jobs are executed based on the server timezone 2024-08-16 12:58:19 +02:00
Thijmen
d86274cc37 Fix styling 2024-06-10 20:43:34 +00:00
Andras Bacsai
a3d73634e7 feat: scheduled task failed notification 2024-05-21 15:36:26 +02:00
Andras Bacsai
5b8a923cb5
Merge pull request #2206 from maurobender/fix_schduled_tasks_executing_using_host_environment
Fix scheduled tasks being executed using host environment variables
2024-05-15 08:58:50 +02:00
Andras Bacsai
317dc10af4 fix: improve scheduled task adding/removing 2024-05-14 15:19:28 +02:00
Mauro E. Bender
cc870ca302 Fix scheduled tasks being executed using host environment variables 2024-05-14 14:29:27 +02:00
Andras Bacsai
ce60a39dc5 Throw RuntimeException instead of Exception when no resource is found in ScheduledTaskJob 2024-01-31 13:45:58 +01:00
Andras Bacsai
d42934f258 fix: sentry error 2024-01-24 11:57:51 +01:00
Andras Bacsai
f1298d1db4 do not send notification of scheduled task failed 2024-01-12 12:44:08 +01:00
Stuart Rowlands
e2e6813632 Functional scheduled executions.
Display last executions.
Support for Services.
2024-01-05 15:06:36 +10:00
Stuart Rowlands
9bbe9567c7 Start scheduled task job execution. 2024-01-01 18:23:58 -08:00