mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 18:52:49 +00:00
The missed daily backups on Coolify Cloud came from Redis evicting queue keys (allkeys-lfu on a full instance), not from the scan of all schedules. The next_run_at design (452259aac,5c5740533) did not prevent that, and it added stored state that must be kept in sync on every frequency, timezone, and server change. It was not released, so remove it: - revert next_run_at, its model hooks, the "Next run" UI, and the diagnostics changes; restore scheduled_job_states and the queue overlap lock - a new migration removes the next_run_at columns and creates scheduled_job_states again where the removed migration already ran Keep the changes that fix real problems: - run the manager every minute from the scheduler with `scheduled:dispatch`, so a busy queue cannot delay it past the catch-up window - load the server chain of scheduled backups with each chunk, which removes about 7,000 queries per run on Coolify Cloud - catch Throwable for each schedule, so one broken schedule does not stop the others - publish database and volume backups again when their queued job was not started after 60 minutes (for example, lost in Redis); log lost tasks and Docker cleanups as missed. A lost backup is not run again when a newer occurrence of the same schedule exists.
75 lines
2.4 KiB
PHP
75 lines
2.4 KiB
PHP
<?php
|
|
|
|
use App\Actions\Database\StartDatabase;
|
|
use App\Actions\Database\StartDatabaseProxy;
|
|
use App\Actions\Service\StartService;
|
|
use App\Jobs\DatabaseBackupJob;
|
|
use App\Jobs\ScheduledJobManager;
|
|
use App\Models\ScheduledDatabaseBackup;
|
|
|
|
describe('deployment_queue helper', function () {
|
|
test('uses the high queue on self-hosted', function () {
|
|
config(['constants.coolify.self_hosted' => true]);
|
|
|
|
expect(deployment_queue())->toBe('high');
|
|
});
|
|
|
|
test('uses the deployments queue on cloud', function () {
|
|
config(['constants.coolify.self_hosted' => false]);
|
|
|
|
expect(deployment_queue())->toBe('deployments');
|
|
});
|
|
});
|
|
|
|
describe('crons_queue helper', function () {
|
|
test('uses the high queue on self-hosted', function () {
|
|
config(['constants.coolify.self_hosted' => true]);
|
|
|
|
expect(crons_queue())->toBe('high');
|
|
});
|
|
|
|
test('uses the crons queue on cloud', function () {
|
|
config(['constants.coolify.self_hosted' => false]);
|
|
|
|
expect(crons_queue())->toBe('crons');
|
|
});
|
|
});
|
|
|
|
describe('start action job routing', function () {
|
|
test('routes to the deployments queue on cloud', function (string $actionClass) {
|
|
config(['constants.coolify.self_hosted' => false]);
|
|
|
|
expect($actionClass::makeJob()->queue)->toBe('deployments');
|
|
})->with([
|
|
StartDatabase::class,
|
|
StartDatabaseProxy::class,
|
|
StartService::class,
|
|
]);
|
|
|
|
test('routes to the high queue on self-hosted', function (string $actionClass) {
|
|
config(['constants.coolify.self_hosted' => true]);
|
|
|
|
expect($actionClass::makeJob()->queue)->toBe('high');
|
|
})->with([
|
|
StartDatabase::class,
|
|
StartDatabaseProxy::class,
|
|
StartService::class,
|
|
]);
|
|
});
|
|
|
|
describe('scheduled job routing', function () {
|
|
test('scheduled jobs use the crons queue on cloud', function () {
|
|
config(['constants.coolify.self_hosted' => false]);
|
|
|
|
expect((new ScheduledJobManager)->queue)->toBe('crons');
|
|
expect((new DatabaseBackupJob(new ScheduledDatabaseBackup))->queue)->toBe('crons');
|
|
});
|
|
|
|
test('scheduled jobs use the high queue on self-hosted', function () {
|
|
config(['constants.coolify.self_hosted' => true]);
|
|
|
|
expect((new ScheduledJobManager)->queue)->toBe('high');
|
|
expect((new DatabaseBackupJob(new ScheduledDatabaseBackup))->queue)->toBe('high');
|
|
});
|
|
});
|