fix: log swallowed reclaim failures + pin ContextVar dispatch invariant (review follow-up for #91217)
This commit is contained in:
@@ -14072,6 +14072,17 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew
|
||||
# parameter, and a keyword call would TypeError into the
|
||||
# failure branch — turning a passing suite into a silent
|
||||
# no-op watcher. Arity is probed above.
|
||||
#
|
||||
# INVARIANT (do not weaken): this task is created inside
|
||||
# ``_profile_runtime_scope(profile_home)`` but typically RUNS
|
||||
# after the scope exits. It still sees the profile's home and
|
||||
# secret scope only because ``set_hermes_home_override`` and
|
||||
# ``set_secret_scope`` are ContextVar-based — ensure_future
|
||||
# copies the current Context into the Task. If either seam is
|
||||
# ever migrated to a thread-local or module global, secondary-
|
||||
# profile handoffs silently regress to primary-config delivery
|
||||
# (the exact bug fixed in #91217) while still recording
|
||||
# handoff_state='completed'.
|
||||
inflight[session_id] = asyncio.ensure_future(
|
||||
_dispatch(row, session_id, session_db, profile_name)
|
||||
)
|
||||
|
||||
@@ -15247,6 +15247,13 @@ class SessionDB(SessionSearchMixin, SessionSchemaMixin, SessionPortabilityMixin)
|
||||
try:
|
||||
return self._execute_write(_do) or []
|
||||
except Exception:
|
||||
# Swallow but never silently: a persistently failing reclaim
|
||||
# leaves poisonous 'running' rows in place (sessions that can
|
||||
# never hand off again), so the operator needs a trace of it.
|
||||
logger.warning(
|
||||
"reclaim_stale_running_handoffs failed; stranded 'running' "
|
||||
"handoff rows (if any) were left in place", exc_info=True,
|
||||
)
|
||||
return []
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user