Repository navigation
feat: v1.5 TTL 惰性淘汰(LIMITATIONS #11 闭环)+ 文档口径收尾 - #11
Merged
Merged
Conversation
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.
目的
闭环 LIMITATIONS #11:
evict_expired早已实现且有测试,但网关主进程没有任何触发器,会话表随运行时间无界增长。方案:惰性淘汰(读写顺手触发,无后台线程)
SessionStore.maybe_evict():在get_or_create(每个正常请求的必经路径)顺手触发淘汰_EVICT_INTERVAL):两次全表扫描至少间隔 60 秒,避免每请求一次扫描;_last_evict竞写良性(最坏多扫一次),不加锁evict_expired取的是同一把非可重入threading.Lock,若在get_or_create临界区内调用必死锁——已在代码注释中写明回归测试(2 项,测试 44 → 46 全过 + 11 项冒烟全过)
test_lazy_eviction_throttled:首次淘汰 1 个超时会话 → 窗口内新超时会话不扫(返回 0)→ 窗口过后恢复淘汰test_get_or_create_triggers_lazy_eviction:任意流量触发,超时会话被 archive、活跃会话不受影响文档同步
验证
python -m unittest tests.test_offline46 项 OK;python tools/smoke_e2e.py11/11 通过(Python 3.13)