Skip to content

Commit 339bf6c

Browse files
fix(core): remove inline ALTER TABLE from postgres_search_repository
Runtime DDL causes deadlocks when two concurrent index jobs race to ALTER TABLE search_vector_chunks simultaneously. The alembic migration m6h7i8j9k0l1_add_vector_sync_fingerprints.py already handles these schema changes — runtime code should never run ALTER TABLE. Fixes #727 Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com> Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
1 parent 8c81d3c commit 339bf6c

File tree

1 file changed

+0
-41
lines changed

1 file changed

+0
-41
lines changed

src/basic_memory/repository/postgres_search_repository.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -318,47 +318,6 @@ async def _ensure_vector_tables(self) -> None:
318318
"""
319319
)
320320
)
321-
await session.execute(
322-
text(
323-
"""
324-
ALTER TABLE search_vector_chunks
325-
ADD COLUMN IF NOT EXISTS entity_fingerprint TEXT
326-
"""
327-
)
328-
)
329-
await session.execute(
330-
text(
331-
"""
332-
ALTER TABLE search_vector_chunks
333-
ADD COLUMN IF NOT EXISTS embedding_model TEXT
334-
"""
335-
)
336-
)
337-
await session.execute(
338-
text(
339-
"""
340-
UPDATE search_vector_chunks
341-
SET entity_fingerprint = COALESCE(entity_fingerprint, ''),
342-
embedding_model = COALESCE(embedding_model, '')
343-
"""
344-
)
345-
)
346-
await session.execute(
347-
text(
348-
"""
349-
ALTER TABLE search_vector_chunks
350-
ALTER COLUMN entity_fingerprint SET NOT NULL
351-
"""
352-
)
353-
)
354-
await session.execute(
355-
text(
356-
"""
357-
ALTER TABLE search_vector_chunks
358-
ALTER COLUMN embedding_model SET NOT NULL
359-
"""
360-
)
361-
)
362321

363322
# --- Embeddings table (dimension-dependent, created at runtime) ---
364323
# Trigger: provider dimensions may differ from what was previously deployed.

0 commit comments

Comments
 (0)