feat(console): persist terminal session routes for restart recovery - #17
Merged
Coooolfan merged 2 commits intoAug 8, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Console 正常重启或进程崩溃后,仍能恢复尚未过期的 terminal session route,使 Worker 重连时继续通过现有恢复握手核对后端资源,调用方随后可以使用原有
session_id和沙箱文件系统。terminal_session_routes表,持久化已确认 route 的 scoped_session_id、node_id 和绝对 leasecommitConfirmedTerminalSessionRoute),数据库写入成功后才更新内存unavailable状态,过期 route 在启动和运行期 janitor 中删除session_not_found、recovery report、Worker 删除和 route janitor 均通过scoped_session_id + node_id条件删除,防止 ABA 覆盖DeleteProvisionedWorker现在返回 error 以暴露持久化故障设计文档:
README/CONSOLE_SESSION_RECOVERY_PLAN.zh-CN.mdStacked on
feat/worker-session-recovery。Test plan
go build ./...go vet ./...gofmt -lon modified filessqlc generateproduces no diffgo test ./internal/grpcserver/...go test ./...(full console suite)