Commit Graph

114 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 05fc5d70c5 Fix: Pass backup timeout to remote SSH process
Allows user-configured backup timeouts > 3600 to be respected. Previously, the SSH process used a hardcoded 3600 second timeout regardless of the job timeout setting. Now the timeout is passed through to instant_remote_process() for all backup operations.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 16:37:38 +01:00
Andras Bacsai 0073d045fb fix: enhance security by validating and escaping database names, file paths, and proxy configuration filenames to prevent command injection 2025-11-27 14:36:31 +01:00
Andras Bacsai fbdd8e5f03 fix: improve robustness and security in database restore flows
- Add null checks for server instances in restore events to prevent errors
- Escape S3 credentials to prevent command injection vulnerabilities
- Fix file upload clearing custom location to prevent UI confusion
- Optimize isSafeTmpPath helper by avoiding redundant dirname calls
- Remove unnecessary --rm flag from long-running S3 restore container
- Prioritize uploaded files over custom location in import logic
- Add comprehensive unit tests for restore event null server handling

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 14:13:10 +01:00
Andras Bacsai 49a3bb0daf refactor(DatabaseBackupJob): remove retry attempts and backoff logic for job execution 2025-11-11 15:39:01 +01:00
Andras Bacsai 334892d1ff feat(BackupNotification): include database name in BackupFailed notification for better context 2025-11-11 15:27:57 +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 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 f315e4bd9c feat: add dev_helper_version to instance settings and update related functionality 2025-11-03 08:38:43 +01:00
Andras Bacsai f50201152f refactor(backup): make backup_log_uuid initialization lazy
Changed backup_log_uuid property to nullable and removed eager initialization in constructor. This allows the ID to be generated when actually needed rather than upfront.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-11 13:42:50 +02:00
Andras Bacsai 2c64136503 feat(backup): enhance backup job with S3 upload handling and notifications
- Introduced a new notification class, BackupSuccessWithS3Warning, to alert users when local backups succeed but S3 uploads fail.
- Updated DatabaseBackupJob to track local backup success and handle S3 upload errors, improving error reporting and user notifications.
- Modified ScheduledDatabaseBackupExecution model to include a new s3_uploaded boolean field for tracking S3 upload status.
- Adjusted views and validation logic to reflect changes in backup execution status and S3 handling.
- Added tests to ensure the new s3_uploaded column is correctly implemented and validated.
2025-10-07 15:02:23 +02:00
Andras Bacsai 8b221552a2 fix(backup): update backup job to use backup_log_uuid for container naming
- Refactored the DatabaseBackupJob to replace instances of backup->uuid with backup_log_uuid for consistency in container naming.
- Ensured that all related Docker commands and processes reference the updated backup_log_uuid, improving clarity and reducing potential errors during backup operations.
2025-10-07 14:05:03 +02:00
Andras Bacsai be9aff3cdc refactor(database-backup): move unique UUID generation for backup execution to database loop
- Refactored the DatabaseBackupJob to generate a unique UUID for each database backup execution within the loop, improving clarity and ensuring uniqueness for each backup attempt.
- Removed redundant UUID generation logic from the initial part of the handle method.
2025-09-23 11:54:10 +02:00
Andras Bacsai 99b101507c feat(databases): implement unique UUID generation for backup execution
- Enhanced the DatabaseBackupJob to generate a unique UUID for each backup execution attempt.
- Added logic to retry UUID generation up to three times if a duplicate is detected, ensuring uniqueness and preventing execution conflicts.
2025-09-23 09:13:10 +02:00
Andras Bacsai 2c8f5415f1 feat(database-backup): enhance error handling and output management in DatabaseBackupJob 2025-09-10 16:13:08 +02:00
peaklabs-dev bc6709e43b fix(backups): s3 backup upload is failing 2025-08-26 18:12:47 +02:00
Andras Bacsai 0dada987a2 feat(backup): add disable local backup option and related logic for S3 uploads 2025-08-17 12:34:20 +02:00
peaklabs-dev a0db5b342f fix(backups): error message if there is no exception 2025-07-18 15:56:01 +02:00
🏔️ Peak e5e1bdcd4d fix(backups): large database backups are not working (#6217) 2025-07-18 15:47:14 +02:00
Andras Bacsai d3f19052ed feat(database-backup): add MongoDB credential extraction and backup handling to DatabaseBackupJob 2025-06-04 11:01:43 +02:00
Andras Bacsai 24b7b53973 Revert "fix(dev): mount points?!"
This reverts commit 365bf3cbf0.
2025-05-05 08:55:44 +02:00
busybox edb4e60478 fix(DatabaseBackupJob): escape PostgreSQL password in backup command (#5759) 2025-05-03 13:34:40 +02:00
Andras Bacsai 365bf3cbf0 fix(dev): mount points?! 2025-05-03 09:59:42 +02:00
Andras Bacsai 34e1587068 refactor(database-backup): remove existing Docker container before backup upload 2025-03-28 22:45:12 +01:00
Andras Bacsai f4575e531f fix(backup): escape special characters in database backup commands 2025-02-03 21:49:13 +01:00
peaklabs-dev 8b6b1b6a9d fix(storage): Hetzner storage buckets not working
- fix: Hetzner buckets do not work for backups
- refactor: removed special handling for Hetzner as it is no longer needed
2025-01-23 18:51:24 +01:00
peaklabs-dev 30f36f96db fix: use finished_at for the end time instead of created_at 2025-01-16 15:12:57 +01:00
peaklabs-dev 9eebeb9241 fix: use new removeOldBackups function
- use the new removeOldBackups function
- only call removeOldBackups function when the backup is completed and also only if the backup is successful
2025-01-13 18:39:22 +01:00
peaklabs-dev fb01aed6d5 feat: new global s3 and local backup deletion function 2025-01-13 16:37:36 +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
Andras Bacsai d58abd1998 refactor 2024-12-16 10:38:18 +01:00
peaklabs-dev 2da4e9a274 feat: enable success messages again 2024-12-09 12:08:27 +01:00
Andras Bacsai 669293afc1 disable success notifications for now 2024-12-03 12:22:27 +01:00
Andras Bacsai cbe44529f9 fix: undefined variable 2024-11-25 11:28:16 +01:00
Andras Bacsai 6ad2e18060 fix: db backup for services 2024-11-24 11:39:26 +01:00
Andras Bacsai 374446b90b fix: do not send internal notification for backups and status jobs 2024-11-22 12:27:13 +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
peaklabs-dev 1c5ddab30d use one constants file 2024-11-12 15:18:48 +01:00
Lucas Michot 8e1444eaa7 Get rid of many useless blank lines 2024-10-31 17:44:01 +01:00
Lucas Michot c5403b0b3f Always prefer ::class notation 2024-10-28 14:56:13 +01:00
Lucas Michot d557a22b91 Remove all ray() calls 2024-10-28 13:51:23 +01:00
Andras Bacsai e8c7d7f972 fix: pull helper image on helper_version change 2024-10-21 12:06:13 +02:00
Andras Bacsai d84d0a816b chore: Refactor DatabaseBackupJob to handle missing team 2024-10-03 20:51:18 +02:00
Andras Bacsai 1c7ca56756 feat: backup all databases for mysql,mariadb,postgresql 2024-10-03 12:39:45 +02:00
Andras Bacsai 059535a676 chore: Remove commented out code for uploading to S3 in DatabaseBackupJob 2024-10-02 16:43:01 +02:00
Andras Bacsai 765a74ca4f handle errors in databasebackupjob 2024-10-02 15:33:14 +02:00
Andras Bacsai dd782e75f5 fix: local dev s3 uploads
fix: hetzner s3 uploads (mc alias instead of mc host)
2024-10-02 11:45:30 +02:00
Andras Bacsai e4108863a8 chore: Remove unnecessary code in DatabaseBackupJob.php 2024-10-01 10:43:04 +02:00
Andras Bacsai 83549965ca Refactor instanceSettings() function for improved code readability 2024-10-01 10:37:40 +02:00