pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #176: Using pgvector on Kubernetes with n > 1 replicas
5+ messages / 3 participants
[nested] [flat]

* [pgvector/pgvector] issue #176: Using pgvector on Kubernetes with n > 1 replicas
@ 2023-07-05 17:07 "ardasahiner (@ardasahiner)" <noreply+ardasahiner@github.com>
  0 siblings, 0 replies; 5+ messages in thread

From: ardasahiner (@ardasahiner) @ 2023-07-05 17:07 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

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?

^ permalink  raw  [nested|flat] 5+ messages in thread

* Re: [pgvector/pgvector] issue #176: Using pgvector on Kubernetes with n > 1 replicas
@ 2023-07-05 17:12 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
  3 siblings, 0 replies; 5+ messages in thread

From: jkatz (@jkatz) @ 2023-07-05 17:12 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ardasahiner This is an issue specific to how you're deploying the Pods on Kubernetes, not pgvector. By default, Kubernetes does not understand how replication works in PostgreSQL. Adding additional replicas in the manner that you did will effectively spawn independent PostgreSQL instances. If you're trying to build out a PostgreSQL cluster, you will have to use a different method, such as an Operator.

^ permalink  raw  [nested|flat] 5+ messages in thread

* Re: [pgvector/pgvector] issue #176: Using pgvector on Kubernetes with n > 1 replicas
@ 2023-07-05 22:53 ` "ardasahiner (@ardasahiner)" <noreply+ardasahiner@github.com>
  3 siblings, 0 replies; 5+ messages in thread

From: ardasahiner (@ardasahiner) @ 2023-07-05 22:53 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Ahh thank you, this is helpful. Closing issue now as it's not pgvector-specific.

^ permalink  raw  [nested|flat] 5+ messages in thread

* Re: [pgvector/pgvector] issue #176: Using pgvector on Kubernetes with n > 1 replicas
@ 2023-07-05 22:53 ` "ardasahiner (@ardasahiner)" <noreply+ardasahiner@github.com>
  3 siblings, 0 replies; 5+ messages in thread

From: ardasahiner (@ardasahiner) @ 2023-07-05 22:53 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ardasahiner closed this.

^ permalink  raw  [nested|flat] 5+ messages in thread

* Re: [pgvector/pgvector] issue #176: Using pgvector on Kubernetes with n > 1 replicas
@ 2025-04-23 04:03 ` "khteh (@khteh)" <noreply+khteh@github.com>
  3 siblings, 0 replies; 5+ messages in thread

From: khteh (@khteh) @ 2025-04-23 04:03 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

https://github.com/pgvector/pgvector/issues/828

^ permalink  raw  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2025-04-23 04:03 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-07-05 17:07 [pgvector/pgvector] issue #176: Using pgvector on Kubernetes with n > 1 replicas "ardasahiner (@ardasahiner)" <noreply+ardasahiner@github.com>
2023-07-05 17:12 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2023-07-05 22:53 ` "ardasahiner (@ardasahiner)" <noreply+ardasahiner@github.com>
2023-07-05 22:53 ` "ardasahiner (@ardasahiner)" <noreply+ardasahiner@github.com>
2025-04-23 04:03 ` "khteh (@khteh)" <noreply+khteh@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