Skip to content

fix: make VectorStore thread-safe for watcher daemon#11

Merged
ernestkoe merged 1 commit intomainfrom
fix/vectorstore-thread-safety
Feb 28, 2026
Merged

fix: make VectorStore thread-safe for watcher daemon#11
ernestkoe merged 1 commit intomainfrom
fix/vectorstore-thread-safety

Conversation

@ernestkoe
Copy link
Collaborator

Summary

  • The file watcher's DebouncedHandler fires callbacks on threading.Timer threads, but VectorStore's SQLite connection enforced same-thread usage — causing every indexing attempt to fail with ProgrammingError
  • Added check_same_thread=False and a threading.Lock to VectorStore, wrapping all public methods for thread-safe access
  • Added TestThreadSafety tests covering cross-thread upsert and concurrent multi-thread upserts

Test plan

  • New thread safety tests pass (TestThreadSafety::test_upsert_from_different_thread, TestThreadSafety::test_concurrent_upserts_from_multiple_threads)
  • All 27 existing tests pass (no regressions)
  • Restarted watcher service — confirmed successful indexing in logs (no more SQLite thread errors)

🤖 Generated with Claude Code

The file watcher's DebouncedHandler fires callbacks on threading.Timer
threads, but VectorStore's SQLite connection was created on the main
thread. This caused every indexing attempt to fail with "SQLite objects
created in a thread can only be used in that same thread".

Add check_same_thread=False and a threading.Lock to VectorStore so all
public methods are safe to call from any thread.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ernestkoe ernestkoe merged commit 36c236a into main Feb 28, 2026
2 checks passed
@ernestkoe ernestkoe deleted the fix/vectorstore-thread-safety branch March 1, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant