From 805361dfbe10dd79ab278fabbc8b2f92992e2464 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 10:18:32 +0000 Subject: [PATCH 1/2] Initial plan From d5df60aec1d876e3f20b80e60c56a252c081a1ca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 10:22:42 +0000 Subject: [PATCH 2/2] Fix sqlite-vector extension loading on multiple connections Co-authored-by: Mte90 <403283+Mte90@users.noreply.github.com> --- db/vector_operations.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/db/vector_operations.py b/db/vector_operations.py index 686e94d..d0c7ded 100644 --- a/db/vector_operations.py +++ b/db/vector_operations.py @@ -21,7 +21,6 @@ # Retry policy for DB-locked operations DB_LOCK_RETRY_COUNT = 6 DB_LOCK_RETRY_BASE_DELAY = 0.05 # seconds, exponential backoff multiplier -_sqlite_vector_loaded = False def connect_db(db_path: str, timeout: float = 30.0) -> sqlite3.Connection: @@ -53,26 +52,19 @@ def load_sqlite_vector_extension(conn: sqlite3.Connection) -> None: CRITICAL: This function will ALWAYS crash the program if the extension fails to load. STRICT mode is mandatory and cannot be disabled. + NOTE: SQLite extensions are loaded per-connection, not per-process. This function must be + called for each connection that needs vector operations. + Args: conn: SQLite database connection Raises: RuntimeError: If the extension fails to load """ - global _sqlite_vector_loaded - - if _sqlite_vector_loaded: - logger.debug("sqlite-vector: already loaded in-process, skipping load.") - return - try: ext_path = importlib.resources.files(SQLITE_VECTOR_PKG) / SQLITE_VECTOR_RESOURCE conn.load_extension(str(ext_path)) - _sqlite_vector_loaded = True - try: - conn.enable_load_extension(False) - except Exception: - pass + logger.debug(f"sqlite-vector extension loaded for connection {id(conn)}") # optional quick check: call vector_version() try: cur = conn.execute(f"SELECT {SQLITE_VECTOR_VERSION_FN}()")