Skip to content

Horizontal scaling deployment causes PGVector violates unique key constraint #666

@cdxvy30

Description

@cdxvy30

Current Behavior

When trying to initialize data manager with following stack (PostgreSQL as scalar storage, PGVector as vector storage and Redis as eviction manager cause' I want to set GPTCache in multi-node K8s environment.)

data_manager = manager_factory(
            manager="postgresql,pgvector",
            eviction_manager="redis",
            scalar_params={
                "sql_url": cache_store_url,
            },
            vector_params={
                "url": vector_store_url,
                "collection_name": "qa_cache",
                "dimension": albert.dimension,
            },
            eviction_params={
                "url": redis_url,
                "maxmemory": f"{CACHE_MAX_SIZE}mb",
                "policy": CACHE_EVICTION,
            }
        )

I encountered:

ERROR: Failed to initialize cache: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "pg_extension_name_index"
DETAIL:  Key (extname)=(vector) already exists.

[SQL: CREATE EXTENSION IF NOT EXISTS vector;]
(Background on this error at: https://sqlalche.me/e/20/gkpj)

Expected Behavior

Connect with Vector storage/Scalar storage and create table, index without reporting errors.

Steps To Reproduce

  1. In a multi-node environment (like K8s), set both Vector storage and Scalar storage with manager_factory, and deploy the application with GPTCache on multi-node.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions