fix: prevent SQLite connection leaks during setup - #517
Merged
Conversation
4 tasks
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.
背景
Python 3.14 测试中偶发出现
aiosqliteworker thread 在 event loop 关闭后回调的警告。调查确认它并非无害时序噪声,而是连接初始化失败或测试清理不完整留下的真实连接资源。Closes #516
变更
do_connect阶段执行 SQLite 文件安全预检,在物理连接建立前拒绝 symlink 等不安全路径。finally中调用真实dispose()完成清理。ResourceWarning强制展示,但不直接升级为异常,以免中断其析构器中的 workerstop()。独立审查与查改
已完成两轮独立 PR diff 审查:
do_connect参数类型注解及 SQLAlchemy 生命周期注释,并补充异步资源泄漏 warning gate。ResourceWarning=error会中断 aiosqlite 析构清理,调整为安全且可见的告警策略;同时恢复连接后的安全复检,保留纵深防御。两轮发现均已查改、重新验证并推送,当前没有遗留的已知问题。
验证
bash ./scripts/doctor.sh:821 passed,覆盖率 93.35%,依赖兼容、pre-commit、mypy、构建及 wheel smoke test 全部通过EventQueuedeprecation warning,与本 PR 无关相关提交
1867994fix: prevent SQLite connection leaks during setup3f1c591test: fail on async resource leak warnings877a4c1fix: preserve SQLite hardening during connection setup风险