Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 1.0.0 under development

- Bug #19: Fix a claimed run being handed out a second time when it waits for a free process slot under `--max-processes`, or is handed out behind a task slower than the reclaim window; the window now starts when the run starts rather than when it was claimed (@KalimeroMK)
- New #19: Record what became of a run: it is claimed as it is handed out and recorded as done, failed, skipped or cancelled once its outcome is known, so a run nobody started is given back to the schedule instead of passing for one that happened, and a claim left by a process that is gone is handed out again. Added `TaskStatus` and `Schedule::reclaimAfter()` (@KalimeroMK)
- Enh #17: Keep a checkpoint record per task instead of one record holding every run emitted at a due time, so that a stored value stays the same size however many tasks share that time and a run costs a single write rather than a write of everything emitted before it (@KalimeroMK)
- Enh #16: Generate a task identifier with a 64-bit hash instead of a 32-bit one, so that a task added to a schedule cannot be taken for one the checkpoint holds under the same identifier (@KalimeroMK)
- Bug #16: Fix a run being skipped, or one already made being repeated, when a task is added to or removed from the schedule while the checkpoint holds the runs of a shared due time; the checkpoint now records which tasks already ran by their identifier instead of by their place in the schedule (@KalimeroMK)
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,31 @@ $schedule = (new Schedule())
->task(...);
```

## What became of a run

A run is claimed in the checkpoint as it is handed out and recorded as `done`, `failed`,
`skipped` or `cancelled` — the cases of `TaskStatus` — once its outcome is known. A run the
scheduler never gets to, because it is shutting down, is given back to the schedule and stays
due rather than passing for a run that happened.

A claim is left behind when the process holding it dies. Every claim is taken back after a
window, set with `reclaimAfter()` and a day by default:

```php
$schedule->reclaimAfter(900); // or a DateInterval
```

The window has to outlast a run, counted from the moment it starts. Under `--max-processes` a
due run waits for a free slot first, and that wait is not charged against the window. Taking a
run back while its process still means to make it runs the task a second time.

A claim made by a process of this host is taken back sooner than that, as soon as the process
is gone, which needs `ext-posix`. Asking about the process only brings the window forward and
never puts it off, so a claim whose process is still there is taken back once the window runs
out as well. A process being alive is no promise that the run is: a pid is given to something
else once the process it belonged to is gone, and a claim waiting on one of those would stand
forever.

## Task identifiers

Every task gets an identifier generated from the cron expression or the interval of its
Expand Down
Loading
Loading