Skip to content

Commit c8c1854

Browse files
HumanBean17claude
andcommitted
fix(tests): revert num_threads=1 and aggressive Kuzu cleanup from failed fix chain
The 5 prior fix attempts introduced num_threads=1 and explicit close/GC in conftest fixtures. These changes ALTERED Kuzu's C++ threading behavior and likely converted a latent race condition into a reliable segfault on CI. The original code (default num_threads, no explicit close) ran fine alongside the LanceDB background thread for months. The real fix is preventing the LanceDB thread from being created (done in prior commits). Reverting these workarounds restores the stable state. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 1b4741b commit c8c1854

2 files changed

Lines changed: 2 additions & 12 deletions

File tree

kuzu_queries.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,7 @@ class KuzuGraph:
337337
def __init__(self, db_path: str) -> None:
338338
self.db_path = db_path
339339
self._db = kuzu.Database(db_path, read_only=True)
340-
# num_threads=1 avoids internal threading that conflicts with pytest-asyncio
341-
self._conn = kuzu.Connection(self._db, num_threads=1)
340+
self._conn = kuzu.Connection(self._db)
342341
self._conn_lock = threading.Lock()
343342

344343
def close(self) -> None:

tests/conftest.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,14 @@ def _session_db_path(tmp_path_factory: pytest.TempPathFactory, name: str) -> Pat
5252
@pytest.fixture(scope="session")
5353
def kuzu_db_path(tmp_path_factory, corpus_root: Path) -> Path:
5454
"""Bank-chat Kuzu DB: pass1–5 + ``write_kuzu`` (no pass6)."""
55-
import gc
56-
5755
import kuzu
5856

5957
from _builders import build_kuzu_to
6058

6159
db_path = _session_db_path(tmp_path_factory, "bank_chat")
6260
build_kuzu_to(corpus_root, db_path, max_pass=5)
6361

64-
db = kuzu.Database(str(db_path), read_only=True)
65-
conn = kuzu.Connection(db, num_threads=1)
62+
conn = kuzu.Connection(kuzu.Database(str(db_path), read_only=True))
6663
n_types = 0
6764
r = conn.execute("MATCH (s:Symbol) WHERE s.kind = 'class' RETURN count(*) AS n")
6865
if r.has_next():
@@ -71,12 +68,6 @@ def kuzu_db_path(tmp_path_factory, corpus_root: Path) -> Path:
7168
r = conn.execute("MATCH ()-[e:INJECTS]->() RETURN count(e) AS n")
7269
n_injects = int(r.get_next()[0] or 0) if r.has_next() else 0
7370
assert n_injects >= 1, "build produced no INJECTS edges"
74-
del r
75-
conn.close()
76-
conn = None
77-
db.close()
78-
db = None
79-
gc.collect()
8071
return db_path
8172

8273

0 commit comments

Comments
 (0)