{"record":{"id":"bc21683c1ed14ef6","repo":"MemPalace/mempalace","slug":"post-recovery-cleanup-failed-after-sum-counts-val","errorCode":null,"errorMessage":"Post-recovery cleanup failed after {sum(counts.values())} rows were rebuilt: {exc}","messagePattern":"Post-recovery cleanup failed after (.+?) rows were rebuilt: (.+?)","errorType":"exception","errorClass":"RebuildCleanupError","httpStatus":null,"severity":"error","filePath":"mempalace/repair.py","lineNumber":2037,"sourceCode":"\n    # Bulk Chroma upserts can leave the derived FTS5 index internally\n    # inconsistent even when all source rows landed.  Rebuild it only after\n    # the backend releases its SQLite handle; otherwise VACUUM cannot obtain\n    # the exclusive lock it needs on Windows.\n    try:\n        _vacuum_and_rebuild_fts5(dest_palace, strict=True)\n    except Exception as exc:\n        message_parts = [\n            f\"Post-recovery cleanup failed after {sum(counts.values())} rows were rebuilt: {exc}\",\n            f\"Recovered palace retained at: {dest_palace}\",\n        ]\n        if archive_path is not None:\n            message_parts.append(f\"Original palace remains archived at: {archive_path}\")\n        else:\n            message_parts.append(f\"Source palace is unchanged at: {source_palace}\")\n        message = \"\\n  \".join(message_parts)\n        print(f\"\\n  ERROR: {message}\")\n        raise RebuildCleanupError(\n            message,\n            counts=dict(counts),\n            dest_palace=dest_palace,\n            archive_path=archive_path,\n        ) from exc\n\n    print(f\"\\n  Rebuild complete. {sum(counts.values())} total rows.\")\n    if archive_path is not None:\n        print(f\"  Original palace archived at: {archive_path}\")\n    print(f\"{'=' * 55}\\n\")\n    return counts\n\n\ndef status(palace_path=None, collection_name: Optional[str] = None) -> dict:\n    \"\"\"Read-only health check: compare sqlite vs HNSW element counts.\n\n    Catches the #1222 failure mode where chromadb's HNSW segment freezes\n    at a stale ``max_elements`` while sqlite keeps accumulating rows.","sourceCodeStart":2019,"sourceCodeEnd":2055,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/repair.py#L2019-L2055","documentation":"Error \"Post-recovery cleanup failed after {sum(counts.values())} rows were rebuilt: {exc}\" thrown in MemPalace/mempalace.","triggerScenarios":"Thrown at mempalace/repair.py:2037 when the library encounters an invalid state.","commonSituations":"Cleanup after a successful rebuild failed.","solutions":["Inspect the cleanup error; rebuilt rows are intact, finish cleanup manually"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}