Skip to content

Commit b73862a

Browse files
committed
fix(db): avoid crash
1 parent 1fc1a2c commit b73862a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

db/vector_operations.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# Retry policy for DB-locked operations
2222
DB_LOCK_RETRY_COUNT = 6
2323
DB_LOCK_RETRY_BASE_DELAY = 0.05 # seconds, exponential backoff multiplier
24+
_sqlite_vector_loaded = False
2425

2526

2627
def connect_db(db_path: str, timeout: float = 30.0) -> sqlite3.Connection:
@@ -58,9 +59,16 @@ def load_sqlite_vector_extension(conn: sqlite3.Connection) -> None:
5859
Raises:
5960
RuntimeError: If the extension fails to load
6061
"""
62+
global _sqlite_vector_loaded
63+
64+
if _sqlite_vector_loaded:
65+
logger.debug("sqlite-vector: already loaded in-process, skipping load.")
66+
return
67+
6168
try:
6269
ext_path = importlib.resources.files(SQLITE_VECTOR_PKG) / SQLITE_VECTOR_RESOURCE
6370
conn.load_extension(str(ext_path))
71+
_sqlite_vector_loaded = True
6472
try:
6573
conn.enable_load_extension(False)
6674
except Exception:

0 commit comments

Comments
 (0)