Skip to content

fix(daemon,pool): registry writes keep an entry they meet mid-replace; tend reads leases under the lock - #545

Merged
7schmiede merged 1 commit into
mainfrom
fix/review-daemon
Nov 16, 2026
Merged

7schmiede merged 1 commit into
mainfrom
fix/review-daemon

Conversation

@7schmiede

Copy link
Copy Markdown
Member

What and why

Findings of the code review of v0.47.0..725e9d2 in the daemon and the pool coordinator (the review is documented internally; the dashboard and hub findings are a PR of their own).

Finding Change Test
Registry write path read once (read_raw, read_in): a write that met its entry mid-replace wrote back only what it set; the stack dropped out of list with its claims one reader read_json for list, read_in, read_raw; change does not write over an entry that is there and does not read a_write_keeps_the_entry_it_met_while_it_was_replaced: red before (claims lost), green after
The retry also waited 200 ms for content that never parses, on every list retry I/O errors and cut-off JSON only an_entry_that_is_no_entry_is_given_up_at_once: red before (> 100 ms), green after
free_range_for held known over registry reads and port probes reads and probes outside the lock; number taken under it, looked for again if another start took it refactor; the end-to-end case of #535 (isolated, this build): lane 1 claimed, the lane starts on +200, lane_renumbered in the log
tend copied leases and waits before the machines' lock read under the lock, right before the idle decision read from the code; provision tests (5 + 115 unit) green, three runs
range_taken asks what listens on services' ports only kept, on purpose: the lane's own containers of an earlier start may still hold its containers' ports at that point (launch_remote stops them after the check); said at the function -

Checks

cargo fmt --check, cargo clippy --workspace --all-targets --locked -D warnings, cargo test -p devstack-daemon (214), cargo test -p devstack-node (lib 115, provision 5, three runs).

Bug class: stale-snapshot.

🤖 Generated with Claude Code

…; tend reads leases under the lock

Findings of the code review of v0.47.0..725e9d2 (documented internally):

- The registry's write path (`read_raw` in `change`, `read_in` in
  `set_claims`) read once: a write that met its entry while another daemon
  replaced it wrote back only the field it set, and the stack dropped out
  of `list` with its claims. One reader (`read_json`) now serves `list`,
  `read_in` and `read_raw`; `change` does not write over an entry that is
  there and does not read.
- That reader retries I/O errors and cut-off JSON only; content that reads
  and does not parse is given up at once, so a broken file no longer costs
  every `list` 200 ms.
- `free_range_for` reads the registry and probes ports without holding
  `known`; it takes the number under the lock, and looks again if another
  start took it meanwhile.
- `tend` reads the leases and the waits under the machines' lock, right
  before it decides whether a machine is idle.
- `range_taken` keeps asking what listens on the services' ports only: the
  lane's own containers may still hold its containers' ports at that point
  (said at the function).

Bug-Class: stale-snapshot
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@7schmiede
7schmiede merged commit ec34f6b into main Nov 16, 2026
14 checks passed
@7schmiede
7schmiede deleted the fix/review-daemon branch November 16, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant