{"record":{"id":"63b868be501d8c2c","repo":"MemPalace/mempalace","slug":"pgvector-does-not-support-maintenance-kind-kind-r","errorCode":null,"errorMessage":"pgvector does not support maintenance kind {kind!r}","messagePattern":"pgvector does not support maintenance kind (.+?)","errorType":"exception","errorClass":"UnsupportedMaintenanceKindError","httpStatus":null,"severity":"warning","filePath":"mempalace/backends/pgvector.py","lineNumber":1294,"sourceCode":"        try:\n            if not self._table_exists():\n                return empty\n            rows = self._client.count_rows(self._table)\n            has_index = self._client.has_vector_index(self._table)\n        except Exception:  # noqa: BLE001 - state report must not raise\n            logger.debug(\"pgvector maintenance state probe failed\", exc_info=True)\n            return empty\n        return {\n            \"row_count\": rows,\n            \"vector_index\": \"hnsw\" if has_index else None,\n            \"index_build_complete\": has_index,\n        }\n\n    def run_maintenance(self, kind: str):\n        from .base import MaintenanceResult, UnsupportedMaintenanceKindError\n\n        if kind not in PgVectorBackend.maintenance_kinds:\n            raise UnsupportedMaintenanceKindError(\n                f\"pgvector does not support maintenance kind {kind!r}\"\n            )\n        self._ensure_open()\n        # Nothing to maintain on a not-yet-materialized table (collection opened\n        # create=True but never written) — return noop rather than letting a\n        # raw \"relation does not exist\" error escape.\n        if not self._table_exists():\n            return MaintenanceResult(kind=kind, status=\"noop\", stats={\"reason\": \"no table\"})\n        if kind == \"analyze\":\n            self._client.analyze_table(self._table)\n            return MaintenanceResult(kind=\"analyze\", status=\"ran\")\n\n        # reindex → build the optional HNSW index. Opt-in: it makes search\n        # approximate, trading the exact-scan 100%-recall default for scale.\n        # Serialized with a session advisory lock so concurrent daemon writers\n        # learn \"already_running\" instead of each stacking an ACCESS EXCLUSIVE\n        # index build.\n        if self._client.has_vector_index(self._table):","sourceCodeStart":1276,"sourceCodeEnd":1312,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/pgvector.py#L1276-L1312","documentation":"run_maintenance() only accepts the maintenance kinds declared in PgVectorBackend.maintenance_kinds (e.g. \"analyze\"). Any other kind string raises UnsupportedMaintenanceKindError before touching the database, per the pluggable-backend maintenance contract in backends/base.py.","triggerScenarios":"Calling run_maintenance(\"vacuum\"), run_maintenance(\"reindex\"), or any kind the pgvector backend has not implemented; passing a kind valid on a different backend (e.g. one ChromaDB supports) to pgvector.","commonSituations":"Generic maintenance scripts that iterate a hard-coded list of kinds across all backends; copying a maintenance call from a ChromaDB deployment to a pgvector one.","solutions":["Check PgVectorBackend.maintenance_kinds (or the backend's describe output) before calling run_maintenance.","Only request kinds the backend declares; for pgvector that is \"analyze\".","Catch UnsupportedMaintenanceKindError in generic tooling and skip/report that kind for this backend."],"exampleFix":"# before\nbackend.run_maintenance(\"vacuum\")\n\n# after\nif \"analyze\" in PgVectorBackend.maintenance_kinds:\n    backend.run_maintenance(\"analyze\")","handlingStrategy":"validation","validationCode":"kinds = getattr(backend, \"maintenance_kinds\", ())\nresults = [backend.run_maintenance(k) for k in requested if k in kinds]","typeGuard":"def supports_maintenance(backend, kind: str) -> bool:\n    return kind in getattr(backend, \"maintenance_kinds\", ())","tryCatchPattern":"from mempalace.backends.base import UnsupportedMaintenanceKindError\ntry:\n    backend.run_maintenance(kind)\nexcept UnsupportedMaintenanceKindError:\n    logger.info(\"skipping %s on %s\", kind, backend.name)","preventionTips":["Read maintenance_kinds off the backend instance instead of hard-coding a global list.","Treat maintenance as best-effort: catch and log unsupported kinds per backend."],"tags":["pgvector","maintenance","unsupported-operation"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}