MemPalace/mempalace · error · BackendError

pgvector connection failed: {exc}

Error message

pgvector connection failed: {exc}

What it means

Error "pgvector connection failed: {exc}" thrown in MemPalace/mempalace.

Source

Thrown at mempalace/backends/pgvector.py:532

                "pgvector backend requires the optional 'psycopg' dependency; "
                "install mempalace[pgvector]"
            ) from exc
        # One client is shared across threads (PgVectorBackend caches a
        # single instance per config), so the read-create-store on self._conn
        # must hold the same lock _execute serializes on; unlocked, two
        # first-connect threads each opened a connection and the loser leaked
        # unclosed. The RLock makes the _execute -> _connect nesting safe. A
        # stalled connect blocks peers under the lock the same way any
        # in-flight query on this single shared connection already does.
        with self._lock:
            if self._closed:
                raise BackendError("pgvector client has been closed")
            if self._conn is not None and not getattr(self._conn, "closed", False):
                return self._conn
            try:
                self._conn = psycopg.connect(self._config.dsn)
            except Exception as exc:  # noqa: BLE001 - surface any driver failure uniformly
                raise BackendError(f"pgvector connection failed: {exc}") from exc
            return self._conn

    def _execute(self, sql: str, params=None, *, fetch: bool = False, many: bool = False):
        with self._lock:
            conn = self._connect()
            try:
                with conn.cursor() as cur:
                    if many:
                        cur.executemany(sql, params or [])
                        rows = None
                    else:
                        cur.execute(sql, params or [])
                        rows = cur.fetchall() if fetch else None
                conn.commit()
            except Exception as exc:  # noqa: BLE001 - normalize to BackendError
                try:
                    conn.rollback()
                except Exception:  # pragma: no cover - rollback best effort

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Check MEMPALACE_PGVECTOR_DSN, that PostgreSQL is reachable, and that credentials are valid

When it happens

Trigger: Thrown at mempalace/backends/pgvector.py:532 when the library encounters an invalid state.

Common situations: Connection to the Postgres server failed at startup.


AI-assisted analysis of MemPalace/mempalace@06cb6987f0 (2026-08-15). Data as JSON: /api/errors/d60e6035a8f47673. Report an issue: GitHub.