mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 21:18:11 -04:00
revert(scheduler): go back to the cron scan and keep the reliability fixes
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.
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ServerRole;
|
||||
use App\Services\ScheduleNextRunRecalculator;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -171,7 +170,6 @@ class ServerSetting extends Model
|
||||
'docker_version_checked_at' => 'datetime',
|
||||
'compose_version_checked_at' => 'datetime',
|
||||
'backup_compression_cpu_percentage' => 'integer',
|
||||
'docker_cleanup_next_run_at' => 'datetime',
|
||||
'server_disk_usage_notification_interval_hours' => 'integer',
|
||||
];
|
||||
|
||||
@@ -193,15 +191,6 @@ class ServerSetting extends Model
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::saving(function ($setting) {
|
||||
if (! $setting->exists || $setting->isDirty(['docker_cleanup_frequency', 'server_timezone'])) {
|
||||
// Without a frequency (a new row that uses the column default), the dispatcher calculates it.
|
||||
$frequency = $setting->getAttributes()['docker_cleanup_frequency'] ?? null;
|
||||
$setting->docker_cleanup_next_run_at = $frequency === null
|
||||
? null
|
||||
: next_cron_run_at($frequency, $setting->server_timezone, now());
|
||||
}
|
||||
});
|
||||
static::creating(function ($setting) {
|
||||
try {
|
||||
if (str($setting->sentinel_token)->isEmpty()) {
|
||||
@@ -215,11 +204,6 @@ class ServerSetting extends Model
|
||||
}
|
||||
});
|
||||
static::updated(function ($settings) {
|
||||
if ($settings->wasChanged('server_timezone') && $settings->server) {
|
||||
// A failure must not fail the settings save: the schedules correct themselves after their next run.
|
||||
rescue(fn () => app(ScheduleNextRunRecalculator::class)->forServer($settings->server));
|
||||
}
|
||||
|
||||
if (
|
||||
$settings->wasChanged('sentinel_token') ||
|
||||
$settings->wasChanged('sentinel_custom_url') ||
|
||||
|
||||
Reference in New Issue
Block a user