mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 01:18:37 +00:00
Fix: Move schedule deletion inside coroutine to prevent job loss
Move the schedule document deletion and unset operation inside the coroutine, after the function is triggered. This ensures the schedule is only deleted after the job is successfully queued, preventing job loss if the container shuts down between coroutine start and completion. This follows the same pattern used in ScheduleMessages.php. Co-authored-by: stnguyen90 <1477010+stnguyen90@users.noreply.github.com>
This commit is contained in:
parent
6a712e236d
commit
e4ebf755e4
1 changed files with 7 additions and 8 deletions
|
|
@ -63,7 +63,7 @@ class ScheduleExecutions extends ScheduleBase
|
|||
|
||||
$this->updateProjectAccess($schedule['project'], $dbForPlatform);
|
||||
|
||||
\go(function () use ($queueForFunctions, $schedule, $scheduledAt, $delay, $data) {
|
||||
\go(function () use ($queueForFunctions, $schedule, $scheduledAt, $delay, $data, $dbForPlatform) {
|
||||
if ($delay > 0) {
|
||||
Co::sleep($delay);
|
||||
}
|
||||
|
|
@ -81,15 +81,14 @@ class ScheduleExecutions extends ScheduleBase
|
|||
->setUserId($data['userId'] ?? '')
|
||||
->trigger();
|
||||
|
||||
$dbForPlatform->deleteDocument(
|
||||
'schedules',
|
||||
$schedule['$id'],
|
||||
);
|
||||
|
||||
$this->recordEnqueueDelay($scheduledAt);
|
||||
unset($this->schedules[$schedule['$sequence']]);
|
||||
});
|
||||
|
||||
$dbForPlatform->deleteDocument(
|
||||
'schedules',
|
||||
$schedule['$id'],
|
||||
);
|
||||
|
||||
unset($this->schedules[$schedule['$sequence']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue