Skip to content

feat(console): persist terminal session routes for restart recovery - #17

Merged
Coooolfan merged 2 commits into
feat/worker-session-recoveryfrom
feat/console-session-recovery
Aug 8, 2026
Merged

feat(console): persist terminal session routes for restart recovery#17
Coooolfan merged 2 commits into
feat/worker-session-recoveryfrom
feat/console-session-recovery

Conversation

@Coooolfan

@Coooolfan Coooolfan commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

Console 正常重启或进程崩溃后,仍能恢复尚未过期的 terminal session route,使 Worker 重连时继续通过现有恢复握手核对后端资源,调用方随后可以使用原有 session_id 和沙箱文件系统。

  • 新增 terminal_session_routes 表,持久化已确认 route 的 scoped_session_id、node_id 和绝对 lease
  • 合并 route 确认与 lease 更新为单一 durable commit(commitConfirmedTerminalSessionRoute),数据库写入成功后才更新内存
  • Console 启动时加载有效 route 为 unavailable 状态,过期 route 在启动和运行期 janitor 中删除
  • session_not_found、recovery report、Worker 删除和 route janitor 均通过 scoped_session_id + node_id 条件删除,防止 ABA 覆盖
  • DeleteProvisionedWorker 现在返回 error 以暴露持久化故障
  • 补齐持久化故障、ABA 场景和 Console 重启全链路测试

设计文档:README/CONSOLE_SESSION_RECOVERY_PLAN.zh-CN.md

Stacked on feat/worker-session-recovery

Test plan

  • go build ./...
  • go vet ./...
  • gofmt -l on modified files
  • sqlc generate produces no diff
  • go test ./internal/grpcserver/...
  • go test ./... (full console suite)
  • Persistence fault tests: upsert/delete failure does not produce in-memory-only confirmed routes
  • ABA tests: late command result, stale reservation clear, late recovery report, cross-node session_not_found
  • Console restart tests: active routes loaded as unavailable, expired routes deleted, full recovery round-trip

Copilot AI lite review requested due to automatic review settings August 8, 2026 08:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Persist confirmed terminal session routes to SQLite so that Console
restarts no longer lose Worker→session ownership. On startup, active
routes are loaded as unavailable and offered as recovery candidates
when the original Worker reconnects. Expired routes are pruned both at
startup and lazily during dispatch.

Key changes:
- Add terminal_session_routes table with scoped_session_id primary key,
  node_id, and absolute lease_expires_unix_ms.
- Merge route confirmation and lease update into a single durable
  commitConfirmedTerminalSessionRoute that persists before updating
  in-memory state.
- Wire session_not_found, recovery report, Worker deletion, and route
  janitor deletions through the persistent store with conditional
  scoped_session_id + node_id matching to prevent ABA overwrites.
- DeleteProvisionedWorker now returns an error when persistence fails.
- Add comprehensive tests for persistence faults, ABA scenarios, and
  full Console restart recovery round-trips.
@Coooolfan Coooolfan changed the title docs: plan console session recovery feat(console): persist terminal session routes for restart recovery Aug 8, 2026
@Coooolfan
Coooolfan merged commit ce9eee1 into main Aug 8, 2026
9 checks passed
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.

2 participants