fix(tracker): serve /tracker/* from tick-independent snapshot - #50
Open
addadi wants to merge 1 commit into
Open
Conversation
tick() holds state.mutex across synchronous dispatch and NullTickets
HTTP calls (heartbeat, claim, reconcile), so /tracker/status, /tasks,
/stats, and /task/{id} all blocked for the duration of the tick —
easily >10s whenever a dispatch was in flight.
TrackerState now publishes a TrackerSnapshot (running-task JSON array,
counts, task_id→detail map) at the end of every tick and once at run()
startup, under a dedicated snapshot_mutex held only for pointer swaps —
never across I/O. Handlers copy the view under that mutex (never
state.mutex) and serve distinguishable errors: 404 tracker-not-
configured, 503 no-snapshot-yet, 500 OOM. Wire format is unchanged
(formatRunningTask moved to tracker.zig as runningTaskJson). The
dispatch path is untouched.
Test proves the decoupling property: copySnapshotView succeeds while
the tick mutex is held by another caller.
Fixes nullclaw#41
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.
Fixes #41
tick()holdsstate.mutexacross synchronous dispatch and NullTickets HTTP calls (heartbeat, claim, reconcile), so/tracker/status,/tracker/tasks,/tracker/stats, and/tracker/task/{id}all blocked for the duration of the tick — easily >10s whenever a dispatch was in flight.TrackerStatenow publishes aTrackerSnapshot(running-task JSON array, counts, task_id→detail map) at the end of every tick and once atrun()startup, under a dedicatedsnapshot_mutexheld only for pointer swaps — never across I/O. Handlers copy the view under that mutex (neverstate.mutex) and serve distinguishable errors: 404 tracker-not-configured, 503 no-snapshot-yet, 500 OOM. Wire format is unchanged (formatRunningTaskmoved totracker.zigasrunningTaskJson). The dispatch path is untouched.Test proves the decoupling property:
copySnapshotViewsucceeds while the tick mutex is held by another caller. Full suite green (zig build test, 357/357).