pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: ardasahiner (@ardasahiner) <noreply+ardasahiner@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #176: Using pgvector on Kubernetes with n > 1 replicas
Date: Wed, 05 Jul 2023 17:07:38 +0000
Message-ID: <gh-pgvector-pgvector-176@github.com> (raw)

When using pgvector on Kubernetes with more than >1 replicas, I encounter some sort of "split brain" problem where the two pods do not share data, despite being mounted on a shared persistent volume. I connect via port-forwarding and find that after creating a table with vectors in it, this table is only present on one pod.

 I was wondering if others have encountered this issue or if there are any issues with the current setup.

Some context that might be helpful and specific error messages:

### Dockerfile
```
FROM ankane/pgvector

CMD ["postgres"]
```
### Relevant snippets of K8s spec
```
spec:
  replicas: 2
    spec:
      containers:
      - env:
        - name: POSTGRES_USER
          valueFrom:
            secretKeyRef:
              key: user
              name: config
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: config
        - name: POSTGRES_DB
          valueFrom:
            secretKeyRef:
              key: db_name
              name: config
        - name: PGDATA
          value: /var/lib/postgresql/data/pgvector
        name: pgvector-test
        volumeMounts:
        - mountPath: /var/lib/postgresql/data
          name: test-pgvector-data
      volumes:
      - name: test-pgvector-data
        persistentVolumeClaim:
          claimName: test-vectordb-pvc
```

### Port-forwarding the service
```
kubectl port-forward service/pgvector-test 5432:5432
```

### Execution & Issue Replication
Once port-forwarded, we can run the `psql` command to open an interactive terminal and run the following commands to replicate this issue
```
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE IF NOT EXISTS Test (
  Id VARCHAR(16),
  Embedding VECTOR(333),
);
```

We can now connect to the individual pods by port-forwarding to each one individually.
- If I list the tables in each pod, i.e. `\dt`, we will see `Test` exist in one pod but not the other.
- If I try to create this table again in the pod that doesn't have it already, I get the error `ERROR: type "vector" does not exist`.
- If I further try to run `CREATE EXTENSION IF NOT EXISTS vector;` on this pod, this command hangs and does not get executed.

Any suggestions for how to resolve this?

view thread (5+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-176@github.com>
Permalink:  ../gh-pgvector-pgvector-176@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox