From 4fb7bbb215605f1be5c3fd2f06d2105921913d0e Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 3 Aug 2025 11:56:04 -0700 Subject: Filer Store: postgres backend support pgbouncer (#7077) support pgbouncer --- weed/credential/postgres/postgres_store.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'weed/credential/postgres/postgres_store.go') diff --git a/weed/credential/postgres/postgres_store.go b/weed/credential/postgres/postgres_store.go index c5fa6e727..58cb3f868 100644 --- a/weed/credential/postgres/postgres_store.go +++ b/weed/credential/postgres/postgres_store.go @@ -8,7 +8,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/credential" "github.com/seaweedfs/seaweedfs/weed/util" - _ "github.com/lib/pq" + _ "github.com/jackc/pgx/v5/stdlib" ) func init() { @@ -52,11 +52,12 @@ func (store *PostgresStore) Initialize(configuration util.Configuration, prefix sslmode = "disable" } - // Build connection string + // Build pgx-optimized connection string + // Note: prefer_simple_protocol=true is only needed for PgBouncer, not direct PostgreSQL connections connStr := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s search_path=%s", hostname, port, username, password, database, sslmode, schema) - db, err := sql.Open("postgres", connStr) + db, err := sql.Open("pgx", connStr) if err != nil { return fmt.Errorf("failed to open database: %w", err) } -- cgit v1.2.3