pgcat icon indicating copy to clipboard operation
pgcat copied to clipboard

"No pool configured for database" when trying to connect to pgcat instance

Open mismaah opened this issue 1 year ago • 1 comments

This is my config.

[general]
port = 6432
admin_username = "admin_user"
admin_password = "admin_pass"

[pools.db]
pool_mode = "session"
default_role = "any"
query_parser_enabled = false
primary_reads_enabled = true
sharding_function = "pg_bigint_hash"

[pools.db.users.0]
# both pg instances have this user with same password
username = "superuser"
password = "pwd"
pool_size = 5

[pools.db.shards.0]
servers = [
    [ "192.168.155.73", 5432, "primary" ],
    [ "192.168.155.74", 5432, "replica" ]
]
database = "test"

I run this in docker and it runs fine without errors:

INFO ThreadId(07) pgcat::pool: Creating a new server connection Address { id: 0, host: "192.168.155.73", port: 5432, shard: 0, database: "test", role: Primary, replica_number: 0, address_index: 0, username: "superuser", pool_name: "db", mirrors: [], stats: AddressStats { total: AddressStatFields { xact_count: 0, query_count: 0, bytes_received: 0, bytes_sent: 0, xact_time: 0, query_time: 0, wait_time: 0, errors: 0 }, current: AddressStatFields { xact_count: 0, query_count: 0, bytes_received: 0, bytes_sent: 0, xact_time: 0, query_time: 0, wait_time: 0, errors: 0 }, averages: AddressStatFields { xact_count: 0, query_count: 0, bytes_received: 0, bytes_sent: 0, xact_time: 0, query_time: 0, wait_time: 0, errors: 0 }, averages_updated: false }, error_count: 0 }    
INFO ThreadId(06) pgcat::pool: Creating a new server connection Address { id: 1, host: "192.168.155.74", port: 5432, shard: 0, database: "test", role: Replica, replica_number: 0, address_index: 1, username: "superuser", pool_name: "db", mirrors: [], stats: AddressStats { total: AddressStatFields { xact_count: 0, query_count: 0, bytes_received: 0, bytes_sent: 0, xact_time: 0, query_time: 0, wait_time: 0, errors: 0 }, current: AddressStatFields { xact_count: 0, query_count: 0, bytes_received: 0, bytes_sent: 0, xact_time: 0, query_time: 0, wait_time: 0, errors: 0 }, averages: AddressStatFields { xact_count: 0, query_count: 0, bytes_received: 0, bytes_sent: 0, xact_time: 0, query_time: 0, wait_time: 0, errors: 0 }, averages_updated: false }, error_count: 0 }

However when I try to connect to it with psql -h 192.168.155.73 -p 6432 -U admin_user db I get the following error even though the pool name matches. Note that I am running this command on 192.168.155.73 In pgcat logs, I see this error

WARN ThreadId(04) pgcat: Client disconnected with error ClientGeneralError("Invalid pool name", ClientIdentifier { application_name: "psql", username: "admin_user", pool_name: "db" })

On the client side, I see this error

psql: error: connection to server at "192.168.155.73", port 6432 failed: FATAL:  No pool configured for database: "db", user: "admin_user"

Am I missing something in the config? Or is this a bug?

Originally posted by @mismaah in https://github.com/postgresml/pgcat/discussions/742

mismaah avatar May 20 '24 06:05 mismaah

try this

[pools.db1.users.0] username = "superuser" password = "pwd" pool_size = 5 [pools.db1.shards.0] servers = [ [ "192.168.155.73", 5432, "primary" ], [ "192.168.155.74", 5432, "replica" ] ] database = "db1"

[pools.db2.users.0] username = "superuser" password = "pwd" pool_size = 5 [pools.db2.shards.0] servers = [ [ "192.168.155.73", 5432, "primary" ], [ "192.168.155.74", 5432, "replica" ] ] database = "db2"

[pools.test.users.0] username = "superuser" password = "pwd" pool_size = 5 [pools.test.shards.0] servers = [ [ "192.168.155.73", 5432, "primary" ], [ "192.168.155.74", 5432, "replica" ] ] database = "test"

eortigoza5 avatar May 21 '24 18:05 eortigoza5

Found the issue. I was trying to connect with psql using the pgcat admin creds rather than the pools...users.0 creds.

mismaah avatar May 23 '24 04:05 mismaah