Skip to content

Intermittent error: WARN new primary chosen #927

@yosemity

Description

@yosemity

Hello. Initial data:

pgdog 0.1.34 x 6 pcs
postgresql 12 to 17

Constant switching, logs show errors like:

WARN database role changed in shard 0
WARN new primary chosen:

Rare errors in application logs:
cannot execute INSERT in a read-only transaction

PostgreSQL clusters are different, located in different data centers, including some with no load.
I tried setting query_parser = "on"`

It got even worse, errors started appearing like:
consuming input failed: no primary server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

There are no network connectivity issues. Again, the pgdog and postgresql versions vary widely; below is just a small example. What could be the cause?

Config example:

pgdog.toml

[general]
host = "0.0.0.0"
port = 6432
workers = 8
default_pool_size = 32
min_pool_size = 1
pooler_mode = "transaction"
load_balancing_strategy = "least_active_connections"
read_write_strategy = "conservative"
query_parser = "off"
query_log = "/var/log/pgdog/query.log"
log_connections = false
log_disconnections = false
passthrough_auth = "enabled_plain"
connect_attempts = 3
connect_attempt_delay = 1
unique_id_min = 1
openmetrics_namespace = "pgdog_"
openmetrics_port = 9090
lsn_check_interval = 5000
lsn_check_timeout = 6000
lsn_check_delay = 5 

[[databases]]
name = "apps"
database_name = "apps"
host = "10.10.200.36"
port = 5432
pool_size = 10
role = "auto"

[[databases]]
name = "apps"
database_name = "apps"
host = "10.22.1.91"
port = 5432
pool_size = 10
role = "auto"

users.toml

[[users]]
name = "apps_ro"
password = "123"
database = "apps"

[[users]]
name = "apps_rw"
password = "xxx"
database = "apps"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions