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 #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 #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 #1177 (merged 2026-04-26), so this is a rebase-edge
fix-up rather than a logic change to their narrowing behaviour.
This commit is contained in:
igorls
2026-04-27 03:01:41 -03:00
parent f5c8b095dd
commit 04c48dd0fe
2 changed files with 8 additions and 6 deletions
+7 -6
View File
@@ -561,12 +561,13 @@ def _fix_blob_seq_ids(palace_path: str) -> None:
"Skipped %d sysdb-10-format BLOB seq_id(s) in embeddings (not converting)", "Skipped %d sysdb-10-format BLOB seq_id(s) in embeddings (not converting)",
skipped, skipped,
) )
if not safe_rows: if safe_rows:
return updates = [
updates = [(int.from_bytes(blob, byteorder="big"), rowid) for rowid, blob in safe_rows] (int.from_bytes(blob, byteorder="big"), rowid) for rowid, blob in safe_rows
conn.executemany("UPDATE embeddings SET seq_id = ? WHERE rowid = ?", updates) ]
logger.info("Fixed %d BLOB seq_ids in embeddings", len(updates)) conn.executemany("UPDATE embeddings SET seq_id = ? WHERE rowid = ?", updates)
conn.commit() logger.info("Fixed %d BLOB seq_ids in embeddings", len(updates))
conn.commit()
except Exception: except Exception:
logger.exception("Could not fix BLOB seq_ids in %s", db_path) logger.exception("Could not fix BLOB seq_ids in %s", db_path)
return return
+1
View File
@@ -507,6 +507,7 @@ def test_fix_blob_seq_ids_skips_sqlite_when_marker_present(tmp_path):
mock_connect.assert_not_called() mock_connect.assert_not_called()
# ── quarantine_stale_hnsw ───────────────────────────────────────────────── # ── quarantine_stale_hnsw ─────────────────────────────────────────────────