Skip to content

fix(lane): a lane started here avoids the ports another stack claims (#535) - #538

Merged
7schmiede merged 1 commit into
mainfrom
fix/lane-start-claims
Nov 16, 2026
Merged

7schmiede merged 1 commit into
mainfrom
fix/lane-start-claims

Conversation

@7schmiede

Copy link
Copy Markdown
Member

What and why

A lane started here could land on ports another stack claims for its lane on a node (#535). The start checked only whether one of its services' ports was in use at that moment; a lane on a node forwards its ports here only once its start there is done. A lane started in between kept its number, and its services failed a minute later with "port … is already in use by another process (devstack.exe)".

The start now also checks the claims of the other stacks on this machine (ADR-0082 point 5) against its whole range, its containers' host ports included, and takes another number when the range is claimed (range_taken in lanes.rs).

What the telemetry showed

On the reporter's machine (devstack 0.46.0), from the pool's telemetry:

UTC
08:55:14 stack A's daemon starts; its lane gets number 4, i.e. A's ports + 400
08:55:44 stack B's new lane gets number 2, B's ports + 200: the same two ports
08:56:07 B's lane starts: the ports are free, nothing listens yet
08:56:38 A's lane is up on the node; A's daemon forwards its ports here
08:56:59 B's api fails: the port is in use by A's daemon

At B's start, A had claimed those ports for 53 s; the new check sees that.

Not explained

Why B's lane got number 2 at 08:55:44, although the numbering (free_number) checks the same claims and A had them for 30 s, is not explained by the data. A candidate: registry::list skips an entry it cannot read or parse without a word, so a read that meets the entry while its daemon replaces it would see no claims. Not proven; the start check now covers the effect.

Checks

  • Unit test a_lane_start_finds_its_range_claimed_before_anything_listens: red on the old check (at the claim), green with the fix; a second wrong variant (claims checked on the services' ports only) is red too.
  • End to end with an isolated LOCALAPPDATA, no hub: stack A with a worktree (lane 1, +100), then a registry entry of another stack claiming lane 1's port, nothing listening; devstack up in the worktree. 0.47.0: the lane starts on +100, on the claimed port. This build: it moves to +200; the claimed port stays free.
  • cargo fmt --check, cargo clippy --workspace --all-targets --locked -D warnings, cargo test -p devstack-daemon.

Bug class and siblings

race-on-start. Siblings, not in this PR:

  • A lane started on, or moved to, a node forwards its ports here by its number, without this check.
  • A lane moved back here (lane move --to local) takes over its ports by its number, without it.
  • The silent skip in registry::list (above).

Refs #535

🤖 Generated with Claude Code

…535)

A lane's start checked only whether one of its services' ports was in use
at that moment. Another stack's lane on a node forwards its ports here only
once its start there is done, so a lane started in between kept a number on
ports another stack had claimed, and its services failed later with "port
… is already in use". The start now also checks the claims of the other
stacks on this machine (ADR-0082 point 5) against its whole range, its
containers' host ports included, and takes another number when its range
is claimed.

Refs #535

Bug-Class: race-on-start
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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