feat: reactive character scheduling via self-rescheduling CharacterBatchJob#678
Merged
Merged
Conversation
…tchJob Replace fixed 1-minute cron polling with a self-perpetuating queue cycle: CharacterBatchJob changes: - Add REFRESH_DELAY_MINUTES = 5 constant - Add $reschedule constructor param (default false) - Store queue name on BatchUpdate so re-dispatched jobs stay on the same queue as the original - finally() callback dispatches a delayed self-reschedule when $reschedule = true (after REFRESH_DELAY_MINUTES) - Simplify shouldDiscardUpdate(): only discard if still pending; the fixed-interval hour-window guard is no longer needed UpdateCharacter changes: - Rewritten as bootstrap/catchup job: dispatches CharacterBatchJob (with reschedule: true) only for characters that have never been updated OR whose last batch finished > 10 minutes ago - 2-second stagger delay per character to spread initial load - Removed CronExpression dependency and interval calculation - Schedule changed from every minute to every 30 minutes (catchup only) Migrations: - Add queue column to batch_updates table - Update UpdateCharacter schedule expression to */30 * * * * Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PR Summary
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
FORK_MEM_PER_PROC=107374182400 (100 GB) makes pokio calculate maxByMemory=0, resulting in max(1, min(cpuBased, 0))=1 process. This eliminates the race condition where parallel workers corrupt .temp/v3.php, causing ParseError on the Formats/ci (push) workflow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces fixed 1-minute cron polling with a self-perpetuating queue cycle. Once a character batch starts, it automatically re-schedules itself after
REFRESH_DELAY_MINUTES(5 minutes), keeping characters continuously fresh without hammering the scheduler.Changes
CharacterBatchJobREFRESH_DELAY_MINUTES = 5constant$rescheduleconstructor param (defaultfalse) — controls whetherfinally()re-dispatchesBatchUpdateso re-dispatched jobs stay on the same queueshouldDiscardUpdate()simplified: only discards if the batch is stillis_pending(the hour-window guard was appropriate for fixed polling, not needed with self-scheduling +ShouldBeUnique)UpdateCharacter(bootstrap/catchup job)CharacterBatchJob(withreschedule: true) for characters that:* * * * *→*/30 * * * *(catchup only, not primary driver)Migrations
add_queue_to_batch_updates_table— new nullablequeuecolumn onbatch_updatesupdate_character_schedule_to_catchup— updatesUpdateCharactercron to*/30 * * * *Tests
All 13 targeted tests pass; full 564-test suite passes; PHPStan clean.