2022-02-08 09:25:59 -08:00
|
|
|
#
|
|
|
|
|
# PgCat config example.
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# General pooler settings
|
|
|
|
|
[general]
|
|
|
|
|
# What IP to run on, 0.0.0.0 means accessible from everywhere.
|
|
|
|
|
host = "0.0.0.0"
|
|
|
|
|
|
|
|
|
|
# Port to run on, same as PgBouncer used in this example.
|
|
|
|
|
port = 6432
|
|
|
|
|
|
2022-08-14 01:25:14 +08:00
|
|
|
# Whether to enable prometheus exporter or not.
|
2022-08-09 15:19:11 -04:00
|
|
|
enable_prometheus_exporter = true
|
|
|
|
|
|
2022-08-14 01:25:14 +08:00
|
|
|
# Port at which prometheus exporter listens on.
|
|
|
|
|
prometheus_exporter_port = 9930
|
|
|
|
|
|
2022-02-08 09:25:59 -08:00
|
|
|
# How long to wait before aborting a server connection (ms).
|
2023-03-10 22:00:28 -06:00
|
|
|
connect_timeout = 5000 # milliseconds
|
2022-02-08 09:25:59 -08:00
|
|
|
|
Allow setting `idle_timeout` for server connections. (#257)
In postgres, you can specify an `idle_session_timeout` which will close
sessions idling for that amount of time. If a session is closed because
of a timeout, PgCat will erroneously mark the server as unhealthy as the next
health check will return an error because the connection was drop, if no
health check is to be executed, it will simply fail trying to send the query
to the server for the same reason, the conn was drop.
Given that bb8 allows configuring an idle_timeout for pools, it would be
nice to allow setting this parameter in the config file, this way you can
set it to something shorter than the server one. Also, server pool will be kept
smaller in moments of less traffic. Actually, currently this value is set as its
default in bb8, which is 10 minutes.
This changes allows setting the parameter using the config file. It can be set both
globally and per pool. When creating the pool, if the pool don't have it defined, global
value is used.
2022-12-16 17:01:00 +01:00
|
|
|
# How long an idle connection with a server is left open (ms).
|
2023-03-10 22:00:28 -06:00
|
|
|
idle_timeout = 30000 # milliseconds
|
2023-03-24 11:20:30 -04:00
|
|
|
|
2023-04-26 16:33:26 -07:00
|
|
|
# Max connection lifetime before it's closed, even if actively used.
|
|
|
|
|
server_lifetime = 86400000 # 24 hours
|
|
|
|
|
|
2023-03-24 11:20:30 -04:00
|
|
|
# How long a client is allowed to be idle while in a transaction (ms).
|
|
|
|
|
idle_client_in_transaction_timeout = 0 # milliseconds
|
Allow setting `idle_timeout` for server connections. (#257)
In postgres, you can specify an `idle_session_timeout` which will close
sessions idling for that amount of time. If a session is closed because
of a timeout, PgCat will erroneously mark the server as unhealthy as the next
health check will return an error because the connection was drop, if no
health check is to be executed, it will simply fail trying to send the query
to the server for the same reason, the conn was drop.
Given that bb8 allows configuring an idle_timeout for pools, it would be
nice to allow setting this parameter in the config file, this way you can
set it to something shorter than the server one. Also, server pool will be kept
smaller in moments of less traffic. Actually, currently this value is set as its
default in bb8, which is 10 minutes.
This changes allows setting the parameter using the config file. It can be set both
globally and per pool. When creating the pool, if the pool don't have it defined, global
value is used.
2022-12-16 17:01:00 +01:00
|
|
|
|
2022-08-08 15:15:48 -05:00
|
|
|
# How much time to give the health check query to return with a result (ms).
|
2023-03-10 22:00:28 -06:00
|
|
|
healthcheck_timeout = 1000 # milliseconds
|
2022-02-08 09:25:59 -08:00
|
|
|
|
2022-08-11 17:42:40 -04:00
|
|
|
# How long to keep connection available for immediate re-use, without running a healthcheck query on it
|
2023-03-10 22:00:28 -06:00
|
|
|
healthcheck_delay = 30000 # milliseconds
|
2022-08-11 17:42:40 -04:00
|
|
|
|
2022-08-08 19:01:24 -04:00
|
|
|
# How much time to give clients during shutdown before forcibly killing client connections (ms).
|
2023-03-10 22:00:28 -06:00
|
|
|
shutdown_timeout = 60000 # milliseconds
|
2022-08-08 19:01:24 -04:00
|
|
|
|
2023-03-10 22:00:28 -06:00
|
|
|
# How long to ban a server if it fails a health check (seconds).
|
2022-07-27 21:47:55 -05:00
|
|
|
ban_time = 60 # seconds
|
2022-02-08 09:25:59 -08:00
|
|
|
|
2022-11-16 22:15:47 -08:00
|
|
|
# If we should log client connections
|
|
|
|
|
log_client_connections = false
|
|
|
|
|
|
|
|
|
|
# If we should log client disconnections
|
|
|
|
|
log_client_disconnections = false
|
|
|
|
|
|
2023-03-10 22:00:28 -06:00
|
|
|
# When set to true, PgCat reloads configs if it detects a change in the config file.
|
2023-04-10 14:51:01 -07:00
|
|
|
autoreload = 15000
|
2022-06-25 11:46:20 -07:00
|
|
|
|
2022-12-16 20:13:13 +01:00
|
|
|
# Number of worker threads the Runtime will use (4 by default).
|
|
|
|
|
worker_threads = 5
|
|
|
|
|
|
2023-03-10 22:00:28 -06:00
|
|
|
# Number of seconds of connection idleness to wait before sending a keepalive packet to the server.
|
|
|
|
|
tcp_keepalives_idle = 5
|
|
|
|
|
# Number of unacknowledged keepalive packets allowed before giving up and closing the connection.
|
|
|
|
|
tcp_keepalives_count = 5
|
|
|
|
|
# Number of seconds between keepalive packets.
|
|
|
|
|
tcp_keepalives_interval = 5
|
|
|
|
|
|
2023-04-11 09:37:16 +08:00
|
|
|
# Path to TLS Certificate file to use for TLS connections
|
2023-04-30 09:41:46 -07:00
|
|
|
# tls_certificate = ".circleci/server.cert"
|
2023-03-10 22:00:28 -06:00
|
|
|
# Path to TLS private key file to use for TLS connections
|
2023-04-30 09:41:46 -07:00
|
|
|
# tls_private_key = ".circleci/server.key"
|
|
|
|
|
|
|
|
|
|
# Enable/disable server TLS
|
|
|
|
|
server_tls = false
|
|
|
|
|
|
|
|
|
|
# Verify server certificate is completely authentic.
|
|
|
|
|
verify_server_certificate = false
|
2022-06-27 09:46:33 -07:00
|
|
|
|
2023-03-10 22:00:28 -06:00
|
|
|
# User name to access the virtual administrative database (pgbouncer or pgcat)
|
2022-07-27 21:47:55 -05:00
|
|
|
# Connecting to that database allows running commands like `SHOW POOLS`, `SHOW DATABASES`, etc..
|
2022-08-08 15:15:48 -05:00
|
|
|
admin_username = "admin_user"
|
2023-03-10 22:00:28 -06:00
|
|
|
# Password to access the virtual administrative database
|
2022-08-08 15:15:48 -05:00
|
|
|
admin_password = "admin_pass"
|
2022-02-08 15:48:28 -08:00
|
|
|
|
2023-05-12 09:50:52 -07:00
|
|
|
# Default plugins that are configured on all pools.
|
|
|
|
|
[plugins]
|
|
|
|
|
|
|
|
|
|
# Prewarmer plugin that runs queries on server startup, before giving the connection
|
|
|
|
|
# to the client.
|
|
|
|
|
[plugins.prewarmer]
|
|
|
|
|
enabled = false
|
|
|
|
|
queries = [
|
|
|
|
|
"SELECT pg_prewarm('pgbench_accounts')",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# Log all queries to stdout.
|
|
|
|
|
[plugins.query_logger]
|
|
|
|
|
enabled = false
|
|
|
|
|
|
|
|
|
|
# Block access to tables that Postgres does not allow us to control.
|
|
|
|
|
[plugins.table_access]
|
|
|
|
|
enabled = false
|
|
|
|
|
tables = [
|
|
|
|
|
"pg_user",
|
|
|
|
|
"pg_roles",
|
|
|
|
|
"pg_database",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# Intercept user queries and give a fake reply.
|
|
|
|
|
[plugins.intercept]
|
|
|
|
|
enabled = true
|
|
|
|
|
|
|
|
|
|
[plugins.intercept.queries.0]
|
|
|
|
|
|
|
|
|
|
query = "select current_database() as a, current_schemas(false) as b"
|
|
|
|
|
schema = [
|
|
|
|
|
["a", "text"],
|
|
|
|
|
["b", "text"],
|
|
|
|
|
]
|
|
|
|
|
result = [
|
|
|
|
|
["${DATABASE}", "{public}"],
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[plugins.intercept.queries.1]
|
|
|
|
|
|
|
|
|
|
query = "select current_database(), current_schema(), current_user"
|
|
|
|
|
schema = [
|
|
|
|
|
["current_database", "text"],
|
|
|
|
|
["current_schema", "text"],
|
|
|
|
|
["current_user", "text"],
|
|
|
|
|
]
|
|
|
|
|
result = [
|
|
|
|
|
["${DATABASE}", "public", "${USER}"],
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
2023-03-10 22:00:28 -06:00
|
|
|
# pool configs are structured as pool.<pool_name>
|
|
|
|
|
# the pool_name is what clients use as database name when connecting.
|
|
|
|
|
# For a pool named `sharded_db`, clients access that pool using connection string like
|
|
|
|
|
# `postgres://sharding_user:sharding_user@pgcat_host:pgcat_port/sharded_db`
|
2022-08-08 15:15:48 -05:00
|
|
|
[pools.sharded_db]
|
2022-07-27 21:47:55 -05:00
|
|
|
# Pool mode (see PgBouncer docs for more).
|
2023-03-10 22:00:28 -06:00
|
|
|
# `session` one server connection per connected client
|
|
|
|
|
# `transaction` one server connection per client transaction
|
2022-07-27 21:47:55 -05:00
|
|
|
pool_mode = "transaction"
|
2022-02-11 11:19:40 -08:00
|
|
|
|
2023-03-10 22:00:28 -06:00
|
|
|
# Load balancing mode
|
|
|
|
|
# `random` selects the server at random
|
|
|
|
|
# `loc` selects the server with the least outstanding busy conncetions
|
|
|
|
|
load_balancing_mode = "random"
|
|
|
|
|
|
|
|
|
|
# If the client doesn't specify, PgCat routes traffic to this role by default.
|
|
|
|
|
# `any` round-robin between primary and replicas,
|
|
|
|
|
# `replica` round-robin between replicas only without touching the primary,
|
|
|
|
|
# `primary` all queries go to the primary unless otherwise specified.
|
2022-02-11 11:21:32 -08:00
|
|
|
default_role = "any"
|
2022-02-18 07:10:18 -08:00
|
|
|
|
2023-10-25 18:11:57 -04:00
|
|
|
# Prepared statements cache size.
|
|
|
|
|
# TODO: update documentation
|
|
|
|
|
prepared_statements_cache_size = 500
|
|
|
|
|
|
2023-03-10 22:00:28 -06:00
|
|
|
# If Query Parser is enabled, we'll attempt to parse
|
2022-02-18 07:10:18 -08:00
|
|
|
# every incoming query to determine if it's a read or a write.
|
|
|
|
|
# If it's a read query, we'll direct it to a replica. Otherwise, if it's a write,
|
|
|
|
|
# we'll direct it to the primary.
|
2022-06-24 14:52:38 -07:00
|
|
|
query_parser_enabled = true
|
2022-02-18 07:10:18 -08:00
|
|
|
|
2023-08-08 16:10:03 -04:00
|
|
|
# If the query parser is enabled and this setting is enabled, we'll attempt to
|
|
|
|
|
# infer the role from the query itself.
|
|
|
|
|
query_parser_read_write_splitting = true
|
|
|
|
|
|
2022-02-18 07:10:18 -08:00
|
|
|
# If the query parser is enabled and this setting is enabled, the primary will be part of the pool of databases used for
|
|
|
|
|
# load balancing of read queries. Otherwise, the primary will only be used for write
|
2022-08-09 15:19:11 -04:00
|
|
|
# queries. The primary can always be explicitly selected with our custom protocol.
|
2022-02-18 07:10:18 -08:00
|
|
|
primary_reads_enabled = true
|
2022-02-23 11:47:24 -08:00
|
|
|
|
2023-02-15 15:19:16 -06:00
|
|
|
# Allow sharding commands to be passed as statement comments instead of
|
|
|
|
|
# separate commands. If these are unset this functionality is disabled.
|
|
|
|
|
# sharding_key_regex = '/\* sharding_key: (\d+) \*/'
|
|
|
|
|
# shard_id_regex = '/\* shard_id: (\d+) \*/'
|
|
|
|
|
# regex_search_limit = 1000 # only look at the first 1000 characters of SQL statements
|
|
|
|
|
|
Allow configuring routing decision when no shard is selected (#578)
The TL;DR for the change is that we allow QueryRouter to set the active shard to None. This signals to the Pool::get method that we have no shard selected. The get method follows a no_shard_specified_behavior config to know how to route the query.
Original PR description
Ruby-pg library makes a startup query to SET client_encoding to ... if Encoding.default_internal value is set (Code). This query is troublesome because we cannot possibly attach a routing comment to it. PgCat, by default, will route that query to the default shard.
Everything is fine until shard 0 has issues, Clients will all be attempting to send this query to shard0 which increases the connection latency significantly for all clients, even those not interested in shard0
This PR introduces no_shard_specified_behavior that defines the behavior in case we have routing-by-comment enabled but we get a query without a comment. The allowed behaviors are
random: Picks a shard at random
random_healthy: Picks a shard at random favoring shards with the least number of recent connection/checkout errors
shard_<number>: e.g. shard_0, shard_4, etc. picks a specific shard, everytime
In order to achieve this, this PR introduces an error_count on the Address Object that tracks the number of errors since the last checkout and uses that metric to sort shards by error count before making a routing decision.
I didn't want to use address stats to avoid introducing a routing dependency on internal stats (We might do that in the future but I prefer to avoid this for the time being.
I also made changes to the test environment to replace Ruby's TOML reader library, It appears to be abandoned and does not support mixed arrays (which we use in the config toml), and it also does not play nicely with single-quoted regular expressions. I opted for using yj which is a CLI tool that can convert from toml to JSON and back. So I refactor the tests to use that library.
2023-09-11 13:47:28 -05:00
|
|
|
# Defines the behavior when no shard is selected in a sharded system.
|
|
|
|
|
# `random`: picks a shard at random
|
|
|
|
|
# `random_healthy`: picks a shard at random favoring shards with the least number of recent errors
|
|
|
|
|
# `shard_<number>`: e.g. shard_0, shard_4, etc. picks a specific shard, everytime
|
2024-11-07 13:17:09 +01:00
|
|
|
# default_shard = "shard_0"
|
Allow configuring routing decision when no shard is selected (#578)
The TL;DR for the change is that we allow QueryRouter to set the active shard to None. This signals to the Pool::get method that we have no shard selected. The get method follows a no_shard_specified_behavior config to know how to route the query.
Original PR description
Ruby-pg library makes a startup query to SET client_encoding to ... if Encoding.default_internal value is set (Code). This query is troublesome because we cannot possibly attach a routing comment to it. PgCat, by default, will route that query to the default shard.
Everything is fine until shard 0 has issues, Clients will all be attempting to send this query to shard0 which increases the connection latency significantly for all clients, even those not interested in shard0
This PR introduces no_shard_specified_behavior that defines the behavior in case we have routing-by-comment enabled but we get a query without a comment. The allowed behaviors are
random: Picks a shard at random
random_healthy: Picks a shard at random favoring shards with the least number of recent connection/checkout errors
shard_<number>: e.g. shard_0, shard_4, etc. picks a specific shard, everytime
In order to achieve this, this PR introduces an error_count on the Address Object that tracks the number of errors since the last checkout and uses that metric to sort shards by error count before making a routing decision.
I didn't want to use address stats to avoid introducing a routing dependency on internal stats (We might do that in the future but I prefer to avoid this for the time being.
I also made changes to the test environment to replace Ruby's TOML reader library, It appears to be abandoned and does not support mixed arrays (which we use in the config toml), and it also does not play nicely with single-quoted regular expressions. I opted for using yj which is a CLI tool that can convert from toml to JSON and back. So I refactor the tests to use that library.
2023-09-11 13:47:28 -05:00
|
|
|
|
2022-02-23 11:47:24 -08:00
|
|
|
# So what if you wanted to implement a different hashing function,
|
|
|
|
|
# or you've already built one and you want this pooler to use it?
|
|
|
|
|
# Current options:
|
2023-03-10 22:00:28 -06:00
|
|
|
# `pg_bigint_hash`: PARTITION BY HASH (Postgres hashing function)
|
|
|
|
|
# `sha1`: A hashing function based on SHA1
|
2022-02-23 11:47:24 -08:00
|
|
|
sharding_function = "pg_bigint_hash"
|
2022-07-27 21:47:55 -05:00
|
|
|
|
2023-04-19 07:45:26 -07:00
|
|
|
# Query to be sent to servers to obtain the hash used for md5 authentication. The connection will be
|
|
|
|
|
# established using the database configured in the pool. This parameter is inherited by every pool
|
|
|
|
|
# and can be redefined in pool configuration.
|
2023-09-01 06:11:38 +09:00
|
|
|
# auth_query="SELECT usename, passwd FROM pg_shadow WHERE usename='$1'"
|
2023-04-19 07:45:26 -07:00
|
|
|
|
|
|
|
|
# User to be used for connecting to servers to obtain the hash used for md5 authentication by sending the query
|
|
|
|
|
# specified in `auth_query_user`. The connection will be established using the database configured in the pool.
|
|
|
|
|
# This parameter is inherited by every pool and can be redefined in pool configuration.
|
|
|
|
|
# auth_query_user = "sharding_user"
|
|
|
|
|
|
|
|
|
|
# Password to be used for connecting to servers to obtain the hash used for md5 authentication by sending the query
|
|
|
|
|
# specified in `auth_query_user`. The connection will be established using the database configured in the pool.
|
|
|
|
|
# This parameter is inherited by every pool and can be redefined in pool configuration.
|
|
|
|
|
# auth_query_password = "sharding_user"
|
|
|
|
|
|
2022-10-25 11:47:41 -07:00
|
|
|
# Automatically parse this from queries and route queries to the right shard!
|
2023-03-10 22:00:28 -06:00
|
|
|
# automatic_sharding_key = "data.id"
|
2022-10-25 11:47:41 -07:00
|
|
|
|
Allow setting `idle_timeout` for server connections. (#257)
In postgres, you can specify an `idle_session_timeout` which will close
sessions idling for that amount of time. If a session is closed because
of a timeout, PgCat will erroneously mark the server as unhealthy as the next
health check will return an error because the connection was drop, if no
health check is to be executed, it will simply fail trying to send the query
to the server for the same reason, the conn was drop.
Given that bb8 allows configuring an idle_timeout for pools, it would be
nice to allow setting this parameter in the config file, this way you can
set it to something shorter than the server one. Also, server pool will be kept
smaller in moments of less traffic. Actually, currently this value is set as its
default in bb8, which is 10 minutes.
This changes allows setting the parameter using the config file. It can be set both
globally and per pool. When creating the pool, if the pool don't have it defined, global
value is used.
2022-12-16 17:01:00 +01:00
|
|
|
# Idle timeout can be overwritten in the pool
|
|
|
|
|
idle_timeout = 40000
|
|
|
|
|
|
2023-03-10 22:00:28 -06:00
|
|
|
# Connect timeout can be overwritten in the pool
|
|
|
|
|
connect_timeout = 3000
|
|
|
|
|
|
2023-05-02 10:26:40 +02:00
|
|
|
# When enabled, ip resolutions for server connections specified using hostnames will be cached
|
|
|
|
|
# and checked for changes every `dns_max_ttl` seconds. If a change in the host resolution is found
|
|
|
|
|
# old ip connections are closed (gracefully) and new connections will start using new ip.
|
|
|
|
|
# dns_cache_enabled = false
|
|
|
|
|
|
|
|
|
|
# Specifies how often (in seconds) cached ip addresses for servers are rechecked (see `dns_cache_enabled`).
|
|
|
|
|
# dns_max_ttl = 30
|
|
|
|
|
|
2023-05-12 09:50:52 -07:00
|
|
|
# Plugins can be configured on a pool-per-pool basis. This overrides the global plugins setting,
|
|
|
|
|
# so all plugins have to be configured here again.
|
|
|
|
|
[pool.sharded_db.plugins]
|
2023-05-03 16:13:45 -07:00
|
|
|
|
2023-05-12 09:50:52 -07:00
|
|
|
[pools.sharded_db.plugins.prewarmer]
|
|
|
|
|
enabled = true
|
|
|
|
|
queries = [
|
|
|
|
|
"SELECT pg_prewarm('pgbench_accounts')",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[pools.sharded_db.plugins.query_logger]
|
2023-05-03 16:13:45 -07:00
|
|
|
enabled = false
|
|
|
|
|
|
2023-05-12 09:50:52 -07:00
|
|
|
[pools.sharded_db.plugins.table_access]
|
2023-05-03 16:13:45 -07:00
|
|
|
enabled = false
|
|
|
|
|
tables = [
|
|
|
|
|
"pg_user",
|
|
|
|
|
"pg_roles",
|
|
|
|
|
"pg_database",
|
|
|
|
|
]
|
|
|
|
|
|
2023-05-12 09:50:52 -07:00
|
|
|
[pools.sharded_db.plugins.intercept]
|
2023-05-03 16:13:45 -07:00
|
|
|
enabled = true
|
|
|
|
|
|
2023-05-12 09:50:52 -07:00
|
|
|
[pools.sharded_db.plugins.intercept.queries.0]
|
2023-05-03 16:13:45 -07:00
|
|
|
|
|
|
|
|
query = "select current_database() as a, current_schemas(false) as b"
|
|
|
|
|
schema = [
|
|
|
|
|
["a", "text"],
|
|
|
|
|
["b", "text"],
|
|
|
|
|
]
|
|
|
|
|
result = [
|
|
|
|
|
["${DATABASE}", "{public}"],
|
|
|
|
|
]
|
|
|
|
|
|
2023-05-12 09:50:52 -07:00
|
|
|
[pools.sharded_db.plugins.intercept.queries.1]
|
2023-05-03 16:13:45 -07:00
|
|
|
|
|
|
|
|
query = "select current_database(), current_schema(), current_user"
|
|
|
|
|
schema = [
|
|
|
|
|
["current_database", "text"],
|
|
|
|
|
["current_schema", "text"],
|
|
|
|
|
["current_user", "text"],
|
|
|
|
|
]
|
|
|
|
|
result = [
|
|
|
|
|
["${DATABASE}", "public", "${USER}"],
|
|
|
|
|
]
|
|
|
|
|
|
2023-03-10 22:00:28 -06:00
|
|
|
# User configs are structured as pool.<pool_name>.users.<user_index>
|
2023-04-11 09:37:16 +08:00
|
|
|
# This section holds the credentials for users that may connect to this cluster
|
2022-08-08 15:15:48 -05:00
|
|
|
[pools.sharded_db.users.0]
|
2023-04-18 09:57:17 -07:00
|
|
|
# PostgreSQL username used to authenticate the user and connect to the server
|
|
|
|
|
# if `server_username` is not set.
|
2022-07-27 21:47:55 -05:00
|
|
|
username = "sharding_user"
|
2023-04-18 09:57:17 -07:00
|
|
|
|
|
|
|
|
# PostgreSQL password used to authenticate the user and connect to the server
|
|
|
|
|
# if `server_password` is not set.
|
2022-07-27 21:47:55 -05:00
|
|
|
password = "sharding_user"
|
2023-04-18 09:57:17 -07:00
|
|
|
|
2023-08-01 17:46:34 -07:00
|
|
|
pool_mode = "transaction"
|
2023-04-18 09:57:17 -07:00
|
|
|
|
|
|
|
|
# PostgreSQL username used to connect to the server.
|
|
|
|
|
# server_username = "another_user"
|
|
|
|
|
|
|
|
|
|
# PostgreSQL password used to connect to the server.
|
|
|
|
|
# server_password = "another_password"
|
|
|
|
|
|
2022-07-27 21:47:55 -05:00
|
|
|
# Maximum number of server connections that can be established for this user
|
|
|
|
|
# The maximum number of connection from a single Pgcat process to any database in the cluster
|
|
|
|
|
# is the sum of pool_size across all users.
|
|
|
|
|
pool_size = 9
|
|
|
|
|
|
2023-04-05 15:06:19 -07:00
|
|
|
|
2022-08-17 01:01:46 +08:00
|
|
|
# Maximum query duration. Dangerous, but protects against DBs that died in a non-obvious way.
|
2023-03-10 22:00:28 -06:00
|
|
|
# 0 means it is disabled.
|
2022-08-13 13:45:58 -07:00
|
|
|
statement_timeout = 0
|
|
|
|
|
|
2022-08-08 15:15:48 -05:00
|
|
|
[pools.sharded_db.users.1]
|
2022-07-27 21:47:55 -05:00
|
|
|
username = "other_user"
|
|
|
|
|
password = "other_user"
|
|
|
|
|
pool_size = 21
|
2022-08-13 13:45:58 -07:00
|
|
|
statement_timeout = 15000
|
2023-11-06 12:18:52 -08:00
|
|
|
connect_timeout = 1000
|
|
|
|
|
idle_timeout = 1000
|
2022-07-27 21:47:55 -05:00
|
|
|
|
2023-03-10 22:00:28 -06:00
|
|
|
# Shard configs are structured as pool.<pool_name>.shards.<shard_id>
|
|
|
|
|
# Each shard config contains a list of servers that make up the shard
|
|
|
|
|
# and the database name to use.
|
2022-08-08 15:15:48 -05:00
|
|
|
[pools.sharded_db.shards.0]
|
2023-03-10 22:00:28 -06:00
|
|
|
# Array of servers in the shard, each server entry is an array of `[host, port, role]`
|
|
|
|
|
servers = [["127.0.0.1", 5432, "primary"], ["localhost", 5432, "replica"]]
|
|
|
|
|
|
|
|
|
|
# Array of mirrors for the shard, each mirror entry is an array of `[host, port, index of server in servers array]`
|
|
|
|
|
# Traffic hitting the server identified by the index will be sent to the mirror.
|
|
|
|
|
# mirrors = [["1.2.3.4", 5432, 0], ["1.2.3.4", 5432, 1]]
|
|
|
|
|
|
2022-07-27 21:47:55 -05:00
|
|
|
# Database name (e.g. "postgres")
|
|
|
|
|
database = "shard0"
|
|
|
|
|
|
2022-08-08 15:15:48 -05:00
|
|
|
[pools.sharded_db.shards.1]
|
2023-03-10 22:00:28 -06:00
|
|
|
servers = [["127.0.0.1", 5432, "primary"], ["localhost", 5432, "replica"]]
|
2022-07-27 21:47:55 -05:00
|
|
|
database = "shard1"
|
|
|
|
|
|
2022-08-08 15:15:48 -05:00
|
|
|
[pools.sharded_db.shards.2]
|
2023-03-10 22:00:28 -06:00
|
|
|
servers = [["127.0.0.1", 5432, "primary" ], ["localhost", 5432, "replica" ]]
|
2022-07-27 21:47:55 -05:00
|
|
|
database = "shard2"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[pools.simple_db]
|
|
|
|
|
pool_mode = "session"
|
|
|
|
|
default_role = "primary"
|
|
|
|
|
query_parser_enabled = true
|
|
|
|
|
primary_reads_enabled = true
|
|
|
|
|
sharding_function = "pg_bigint_hash"
|
|
|
|
|
|
|
|
|
|
[pools.simple_db.users.0]
|
|
|
|
|
username = "simple_user"
|
|
|
|
|
password = "simple_user"
|
|
|
|
|
pool_size = 5
|
2023-04-26 16:33:26 -07:00
|
|
|
min_pool_size = 3
|
|
|
|
|
server_lifetime = 60000
|
2022-08-13 13:45:58 -07:00
|
|
|
statement_timeout = 0
|
2022-07-27 21:47:55 -05:00
|
|
|
|
|
|
|
|
[pools.simple_db.shards.0]
|
|
|
|
|
servers = [
|
|
|
|
|
[ "127.0.0.1", 5432, "primary" ],
|
|
|
|
|
[ "localhost", 5432, "replica" ]
|
|
|
|
|
]
|
|
|
|
|
database = "some_db"
|