You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
session wait can answer idle during a reattach that holds a pending permission #557
TestDetachedPermissionReraisedAfterRestart (e2e/features/g11_detached_reattach_test.go:421) fails under load: wait after the restart exited 0 with state "idle", want 1 and asking. A relay session wait that arrives while relay is reattaching a detached session after a restart can answer idle, although the session holds a pending permission prompt.
Seen on epic/525-session-adoption at ba4cae1: 1 of 10 with -count=10 under 8 CPU burners (0 of 10 without load). Also seen once in a full suite at -parallel 32 on a branch whose change does not reach this test.
Root cause
Manager.Wait calls reattachIfDetached, which calls m.Get(id) (internal/sessions/session/manager.go:1737, :1010). While the startup reattach's Create is in flight, Get blocks on the slot's done channel (manager.go:762-764). Create signals Launched (the session goes idle), closes slot.done, and only then calls m.announceAttach(sess) (manager.go:420-422), which re-raises the held permission and sets the session to asking. The woken Wait reads Idle in that gap (manager.go:1757) and returns 0.
Log order in the failing run (relaysessions.log): agent attached, starting to idle, session.wait answers, idle to running to asking, all within 2 ms.
Fix
Announce the attach before close(slot.done), or have Wait read the state only after the attach is announced. A red e2e repro first (the existing test under load, or a forced delay).
Activity