Repository navigation
feat(session): distributed Redis-backed idle auto-commit scheduler - #6046
Merged
qin-ctx merged 8 commits intoOct 15, 2026
Merged
Conversation
- Remove docs/zh/design session-idle-auto-commit scheduler design docs - Rename tests/scheduling/expiry/test_config.py to test_expiry_config.py to avoid pytest module-name collision with tests/unit/crypto/test_config.py Co-authored-by: TRAE CLI <traecli@bytedance.com>
…o-commit # Conflicts: # Dockerfile # MANIFEST.in # openviking/server/bootstrap.py # pyproject.toml # setup.py # uv.lock
qin-ctx
requested changes
Oct 14, 2026
qin-ctx
left a comment
Collaborator
There was a problem hiding this comment.
用 Redis 到期索引替代全量 session 扫描,方向有价值;复用现有归档和队列流程也合理。
当前接入还未保持已有自动提交契约,并存在受支持 Python 版本下的运行问题。请先解决行内标出的 4 个阻塞问题再合入。另有 1 条关于额外元数据读写的非阻塞设计建议,请结合生命周期约束说明取舍。
qin-ctx
approved these changes
Oct 15, 2026
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.
Description
当前内核的 session 空闲超时自动提交依赖后台周期扫描全量 session 的
.meta.json,在 session 数量大时存在存储 IO 与性能问题。本 PR 新增一套可选的、基于 Redis 的分布式 expiry 调度能力,把"发现到期 session"从轮询扫描改为按分钟桶精准调度,并保持默认行为(
idle_backend=legacy)与现有提交语义完全不变。Human Involvement
Related Issue
Type of Change
Changes Made
openviking/scheduling/expiry/分布式 expiry 调度模块:业务接入 facade/registry、Redis 资源桶与分钟调度桶、publisher、callback consumer、临时 shard 租约、runtime/shard_runner 生命周期,以及一组原子 Lua 脚本。openviking/service/session_expiry.py,在服务层完成纯 idle 检查后直接复用原Session.commit_async,不在业务锁内做原子检查+提交,也不新增 idle 专用提交 API。SessionService.commit_on_timeout改为加载最新 session/meta 后在服务层检查,取代旧的"锁内 idle 检查 + idle 归档恢复"路径;idle_backend可选legacy(默认,行为不变)或redis。openviking/server/bootstrap.py支持在publisher_separate_process=true时由openviking-server拉起/回收内部 publisher 子进程;新增openviking_cli/expiry_bootstrap.py与 expiry 配置项(service_name、shard_count、session_consumer_concurrency、redis.*)。auto_commit_policy.py为 idle 超时写入增加下限校验(MIN_IDLE_TIMEOUT_SECONDS),默认策略常量保持不变。docs/zh|en/guides/01-configuration.md、docs/zh|en/api/05-sessions.md。tests/scheduling/expiry/全套用例,以及 session 提交、bootstrap、policy、expiry publisher 相关测试。Testing
本分支相关测试套件本地全绿:
tests/scheduling/expiry/、tests/session/test_session_commit.py、tests/unit/test_server_bootstrap_expiry_publisher.py、tests/unit/session/test_auto_commit_policy.py、tests/server/ test_bootstrap.py。说明:仓库
tests/server/test_api_sessions.py中有 5 个失败用例,经核验为 main 上已有的旧账(默认策略常量在历史提交98a0104aa改过,断言未同步更新),与本 PR 改动无关。Checklist
Additional Notes
idle_backend=legacy,不配置 Redis 时行为与现状一致。