mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 15:39:59 +00:00
CleanupInstanceStuffsJob, CleanupOrphanedPreviewContainersJob, and CheckMissingDatabaseBackupsJob had no uniqueFor. A lock left by a stopped worker blocked them for up to 24 hours. - Set uniqueFor to 60, 600, and 1800 seconds - Give CheckMissingDatabaseBackupsJob a 1800 second timeout, so a run cannot outlive its lock
34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
use App\Jobs\CheckMissingDatabaseBackupsJob;
|
|
use App\Jobs\CleanupInstanceStuffsJob;
|
|
use App\Jobs\CleanupOrphanedPreviewContainersJob;
|
|
use Illuminate\Support\Facades\Queue;
|
|
|
|
beforeEach(function () {
|
|
config()->set('cache.default', 'array');
|
|
Queue::fake();
|
|
});
|
|
|
|
dataset('scheduled instance jobs', [
|
|
'orphaned preview containers cleanup' => [CleanupOrphanedPreviewContainersJob::class, 600],
|
|
'instance cleanup' => [CleanupInstanceStuffsJob::class, 60],
|
|
'missing database backups check' => [CheckMissingDatabaseBackupsJob::class, 1800],
|
|
]);
|
|
|
|
it('does not queue the job again while its unique lock is held', function (string $jobClass, int $lockSeconds) {
|
|
$jobClass::dispatch();
|
|
$this->travel($lockSeconds - 1)->seconds();
|
|
$jobClass::dispatch();
|
|
|
|
Queue::assertPushed($jobClass, 1);
|
|
})->with('scheduled instance jobs');
|
|
|
|
it('queues the job again after a unique lock left by a killed worker expires', function (string $jobClass, int $lockSeconds) {
|
|
$jobClass::dispatch();
|
|
$this->travel($lockSeconds + 1)->seconds();
|
|
$jobClass::dispatch();
|
|
|
|
Queue::assertPushed($jobClass, 2);
|
|
})->with('scheduled instance jobs');
|