{"record":{"id":"d60e6035a8f47673","repo":"MemPalace/mempalace","slug":"pgvector-connection-failed-exc","errorCode":null,"errorMessage":"pgvector connection failed: {exc}","messagePattern":"pgvector connection failed: (.+?)","errorType":"exception","errorClass":"BackendError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/pgvector.py","lineNumber":532,"sourceCode":"                \"pgvector backend requires the optional 'psycopg' dependency; \"\n                \"install mempalace[pgvector]\"\n            ) from exc\n        # One client is shared across threads (PgVectorBackend caches a\n        # single instance per config), so the read-create-store on self._conn\n        # must hold the same lock _execute serializes on; unlocked, two\n        # first-connect threads each opened a connection and the loser leaked\n        # unclosed. The RLock makes the _execute -> _connect nesting safe. A\n        # stalled connect blocks peers under the lock the same way any\n        # in-flight query on this single shared connection already does.\n        with self._lock:\n            if self._closed:\n                raise BackendError(\"pgvector client has been closed\")\n            if self._conn is not None and not getattr(self._conn, \"closed\", False):\n                return self._conn\n            try:\n                self._conn = psycopg.connect(self._config.dsn)\n            except Exception as exc:  # noqa: BLE001 - surface any driver failure uniformly\n                raise BackendError(f\"pgvector connection failed: {exc}\") from exc\n            return self._conn\n\n    def _execute(self, sql: str, params=None, *, fetch: bool = False, many: bool = False):\n        with self._lock:\n            conn = self._connect()\n            try:\n                with conn.cursor() as cur:\n                    if many:\n                        cur.executemany(sql, params or [])\n                        rows = None\n                    else:\n                        cur.execute(sql, params or [])\n                        rows = cur.fetchall() if fetch else None\n                conn.commit()\n            except Exception as exc:  # noqa: BLE001 - normalize to BackendError\n                try:\n                    conn.rollback()\n                except Exception:  # pragma: no cover - rollback best effort","sourceCodeStart":514,"sourceCodeEnd":550,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/pgvector.py#L514-L550","documentation":"Error \"pgvector connection failed: {exc}\" thrown in MemPalace/mempalace.","triggerScenarios":"Thrown at mempalace/backends/pgvector.py:532 when the library encounters an invalid state.","commonSituations":"Connection to the Postgres server failed at startup.","solutions":["Check MEMPALACE_PGVECTOR_DSN, that PostgreSQL is reachable, and that credentials are valid"],"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"}