test: reproduce #198 — setup_schedule runs before lock acquisition - #327
Open
sibson wants to merge 1 commit into
Open
test: reproduce #198 — setup_schedule runs before lock acquisition#327sibson wants to merge 1 commit into
sibson wants to merge 1 commit into
Conversation
RedBeatScheduler.__init__ runs setup_schedule() via the base Scheduler constructor (non-lazy), which happens before beat_init fires and before self.lock is ever set. A second instance started with a different beat_schedule -- e.g. during a rolling release -- overwrites the statics set the lock-holding instance is running, whether or not it goes on to acquire the lock itself. expectedFailure until the fix lands. TRIAGE ARTIFACT: move to tests/test_scheduler.py at fix time, per the docstring.
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.
What this is
A failing regression test for #198, not a fix. Confirms the report:
setup_schedule()writes static entries and the:staticsset unconditionally, and runs fromRedBeatScheduler.__init__(the baseSchedulerconstructor is non-lazy) — which happens beforebeat_initfires and beforeself.lockis ever set. A second instance started with a differentbeat_scheduleoverwrites the statics set the lock-holding instance is actually running, regardless of whether it goes on to win the lock itself.Not documented as intended:
docs/design.rstcovers lock ownership for ticking, not for schedule installation.Test
Marked
@unittest.expectedFailureso CI stays green. Whoever fixes this drops the marker and the test becomes the regression check — see theTRIAGE ARTIFACTdocstring for where it should move (tests/test_scheduler.py).Full suite unaffected: 90 tests, 2 pre-existing
evalshaerrors (missingfakeredis[lua]dev dependency, unrelated to this change), 2 skips, 1 expected failure (this one).On the reporter's proposed
InstallOnTickSchedulersubclassThe shape is right, and gating
tick()on the lock is doing necessary work rather than being belt-and-braces, sincesetup_schedule()runs from__init__beforeself.lockcan possibly be set — gating only there would mean it never runs at all. Two things worth considering for whoever picks this up:tick()reruns the full install on every tick, not just the first one after acquisition.update_from_dictpreserveslast_run_atso it isn't destructive, but it is a rewrite of every static entry per tick; latching it (run once, on first lock acquisition) would avoid that.setup_schedule()— which deletes entries missing from this instance's config — is the sharp end and needs to be behind the lock in any fix.Closes nothing; a maintainer decision on the actual fix approach is still needed.