HydraIssues

Orphaned session holds a body slot forever: no head ever adopts it and no watchdog can see it
open bug Project: hydracluster Reporter: 24 Oct 2026 09:59

Description

A body opens a session, Sunshine keeps the app running with no client attached, no head ever adopts the record, and nothing in the cluster can ever close it. The body slot is held until an operator closes the app by hand.

WHY NO WATCHDOG CATCHES IT (pkg/api/session_watchdog.go)

  • staleHead is guarded on !rec.HeadLastHeartbeatAt.IsZero(). A session no head adopted has a ZERO head heartbeat, which is exactly the orphan's signature, so the head-side check skips it.
  • bodyGoneThreshold (10 min) never fires, because the body goes on heartbeating normally.
  • requestStaleTermination refuses the record a second time: it returns false when rec.StreamingClientUUID is empty, and an orphan has no client uuid. So even if the scan had seen it, the stop could not have been issued.

MEASURED, Mercator bed, venue cloud-seven

  • 2026-10-24 06:53 UTC: cosmic-pretzel-98 held a session started 2026-10-23T08:36:05Z and boom-pickle-38 one started 2026-10-23T11:57:05Z. Both head_last_heartbeat_at = 0001-01-01, both with a current body heartbeat. 22 h and 19 h. map-37 and map-39 were out of service for that whole time.
  • 2026-10-24 08:05 UTC: all three bodies at free_slots 0 again, one of them from a session 50 seconds old that was already unadopted.
  • 2026-10-24 09:45 UTC: again on two bodies.
  • The head reports 'No body available', which is true and hides the cause. Judge it by the session started_at, not by the head.

OPERATOR WORKAROUND
curl -sk -u sunshine:sunshine -X POST -H 'Content-Type: application/json' -d '{}' https://:47990/api/apps/close
Then serverinfo on 47989 must read SUNSHINE_SERVER_FREE. The cluster releases the slot about 15 s later.

FIX
An adoption deadline in the watchdog: reap a session only when all four hold - the head heartbeat is zero, the body reports no streaming client, the session is older than 5 minutes, and no online head names that body in LiveBodyID. The stop must go out on the LEGACY body-wide path, because an owned stop is fenced on a client uuid the orphan does not have. Adoption was measured at 39 s to 92 s, so the deadline is more than three times the worst observed wait.

A session that is unadopted but DOES carry a client uuid is left alone: it may be a viewer paired straight to Sunshine, which no cluster record can rule out.

Related: #816 (a streaming head reported as self-service), #663 / #711 (body allocation), #504 (the designed slot allocator).

Session Context

Venue
cloud-seven