Skip to content

Commit 0ea5b85

Browse files
igorlslealvona
authored andcommitted
fix(chroma): write blob-fix marker even when narrowing skips all rows
The narrowed _fix_blob_seq_ids returned early when safe_rows was empty, but MemPalace#1177's marker contract requires the marker to be written on every successful pass — even no-op — so subsequent opens skip the sqlite3 connection entirely. Without this, palaces that have no genuine 0.6.x BLOBs but DO have sysdb-10-prefixed rows would re-open sqlite3 on every call, defeating the MemPalace#1090 corruption guard. Restructured the conditional so the marker write is unconditional after a successful sqlite scan, regardless of whether any rows were updated. Surfaced by test_fix_blob_seq_ids_writes_marker_when_already_integer during the develop-rebase of this PR. The author's branch predates the marker contract from MemPalace#1177 (merged 2026-04-26), so this is a rebase-edge fix-up rather than a logic change to their narrowing behaviour.
1 parent ded699f commit 0ea5b85

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

mempalace/backends/chroma.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,12 +561,13 @@ def _fix_blob_seq_ids(palace_path: str) -> None:
561561
"Skipped %d sysdb-10-format BLOB seq_id(s) in embeddings (not converting)",
562562
skipped,
563563
)
564-
if not safe_rows:
565-
return
566-
updates = [(int.from_bytes(blob, byteorder="big"), rowid) for rowid, blob in safe_rows]
567-
conn.executemany("UPDATE embeddings SET seq_id = ? WHERE rowid = ?", updates)
568-
logger.info("Fixed %d BLOB seq_ids in embeddings", len(updates))
569-
conn.commit()
564+
if safe_rows:
565+
updates = [
566+
(int.from_bytes(blob, byteorder="big"), rowid) for rowid, blob in safe_rows
567+
]
568+
conn.executemany("UPDATE embeddings SET seq_id = ? WHERE rowid = ?", updates)
569+
logger.info("Fixed %d BLOB seq_ids in embeddings", len(updates))
570+
conn.commit()
570571
except Exception:
571572
logger.exception("Could not fix BLOB seq_ids in %s", db_path)
572573
return

tests/test_backends.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ def test_fix_blob_seq_ids_skips_sqlite_when_marker_present(tmp_path):
507507

508508
mock_connect.assert_not_called()
509509

510+
510511
# ── quarantine_stale_hnsw ─────────────────────────────────────────────────
511512

512513

0 commit comments

Comments
 (0)