Skip to content

[backport-0.21] fix(engine): decouple active-clients API from session lifecycle locks - #13865

Closed
matipan wants to merge 0 commit into
dagger:backport-0.21from
matipan:backport-13542-0.21
Closed

matipan wants to merge 0 commit into
dagger:backport-0.21from
matipan:backport-13542-0.21

Conversation

@matipan

@matipan matipan commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport #13542 to the v0.21 maintenance line for v0.21.9.

The Cloud keeper polls engine { clients } as part of its composite heartbeat. On v0.21, that enumeration can block behind one session lifecycle lock held across initialization or teardown. Because the keeper does not publish until the query returns, one slow session can suppress all keeper heartbeats, make a live engine unschedulable, and eventually cause suspension.

This backport decouples active-client observers from session lifecycle work while preserving the complete synchronization redesign from the source fix.

Source

v0.21 adaptation

The main-only wcprofEnabled field from #13393 does not exist on v0.21 and is not a dependency, so the conflict-only field and assignment were omitted.

This is not a reduced Clients unlock. It retains the full semantic unit:

  • immutable session identity before registry publication
  • atomic lifecycle state
  • lifecycle-only mutex
  • lock-free Clients, activeClientIDs, and clientFromIDs observers
  • client publication only after successful initialization
  • removed tombstones and pointer-conditional registry deletion
  • client DB opening outside clientMu
  • graceful-stop session snapshot
  • all source liveness/race regressions adapted to v0.21

Validation

Passed:

  • gofmt -w engine/server/server.go engine/server/session.go engine/server/session_test.go
  • go test ./engine/server -run "^(TestClientsDoesNotBlockWhileSessionLifecycleLocked|TestActiveClientIDsDoesNotBlockWhileSessionLifecycleLocked|TestGetOrInitClientReturnsFastForRemovedTombstone|TestClientFromIDsStateGating|TestSessionLifecycleObserverConcurrency)$" -count=1
  • go test ./engine/server
  • go test -race ./engine/server
  • git diff --check origin/backport-0.21...HEAD

Release note

Adds .changes/unreleased/Fixed-20260810-150651.yaml for v0.21.9, attributed to source PR #13542.

Cloud-side per-operation deadlines remain separate follow-up work and are not changed by this backport.

@grouville

grouville commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

cc @sipsma @matipan unsure abotu the status of this PR 🙏

@matipan

matipan commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@grouville Closing it given that Erik's #13884 has this change plus some others!

@matipan matipan closed this Aug 20, 2026
@matipan
matipan force-pushed the backport-13542-0.21 branch from 35afbde to 00c993c Compare August 20, 2026 13:13
@matipan
matipan deleted the backport-13542-0.21 branch August 20, 2026 13:16
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.

3 participants