Skip to content

fix(searcher): bound per-path wait and non-blocking shutdown - #2194

Open
RerankerGuo wants to merge 1 commit into
MemTensor:mainfrom
RerankerGuo:fix/issue-2134-searcher-thread-leak
Open

fix(searcher): bound per-path wait and non-blocking shutdown#2194
RerankerGuo wants to merge 1 commit into
MemTensor:mainfrom
RerankerGuo:fix/issue-2134-searcher-thread-leak

Conversation

@RerankerGuo

Copy link
Copy Markdown
Contributor

Summary

  • Bound each retrieval path's Future.result() wait to 30s so a slow / blocked path (e.g. hanging Neo4j / HTTP call) cannot stall the whole searcher.
  • Replaced the with ContextThreadPoolExecutor(...) block with explicit executor.shutdown(wait=False) in a finally: block so straggling threads never pin the pool.
  • Added a unit test verifying _retrieve_paths returns even when one path is artificially slow.

Closes #2134.

Verification

  • ruff format / ruff check clean on changed lines.
  • New test test_retrieve_paths_timeout_releases_executor simulates a 5s-hanging path and asserts the total elapsed is well below the 30s bound.

Checklist

  • Local ruff format / check ran clean.
  • Tests added for the new timeout / shutdown behaviour.
  • Backward compatible — happy-path behaviour unchanged.

Searcher._retrieve_paths previously joined every retrieval path with
Future.result() (no timeout) inside a ContextThreadPoolExecutor
context-manager, so a single slow / blocked path (e.g. a hanging
Neo4j or HTTP call) would stall the whole searcher and pin worker
threads until process exit.

Add a per-path timeout (30s) on each future and release the pool via
executor.shutdown(wait=False) in a finally block, guaranteeing no
thread leak on any pathological path. Added a unit test covering the
slow-path branch.
Closes MemTensor#2134.
@Memtensor-AI Memtensor-AI added area:memory 记忆存储、检索、更新、召回逻辑 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:memory 记忆存储、检索、更新、召回逻辑 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants