hapostgres / pg_auto_failover

Postgres extension and service for automated failover and high-availability
Other
1.07k stars 112 forks source link

The environment variable PGDATABASE does not take effect #953

Closed lkgGitHub closed 1 year ago

lkgGitHub commented 1 year ago

Citus Cluster Quick Start

I modify the environment variable PGDATABASE in pg_auto_failover/docs/citus. and run docker-compose up.

Database is still citus.

coordinator log

ERROR Monitor ERROR:  node citus-coordinator-0:5432 with dbname "my_database" can not be registered in formation "default" which expects dbname "citus"

Then I update monitor database by sql.

update pgautofailover.formation set dbname='my_database' where formationid='default';

coordinator success, but worker is still failed. worker log:

ERROR Monitor ERROR:  node citus-worker-0:5432 with dbname "citus" can not be registered in formation "default" which expects dbname "my_database"
DimCitus commented 1 year ago

Hi @lkgGitHub ; thanks for reporting this issue. I have now implemented a fix for it. You have two problems in your script:

  1. the PGDATABASE option is not used at pg_autoctl create ... time, which means defaults (here, "citus") is still used,
  2. when the first node is registered to the monitor, the formation is created with the expected database name; which is then enforced to be the same in all members of the same formation.

You could hack (UPDATE) the pgautofailover.formation entry on the monitor to allow nodes to register with the database name you need, or simply use the option --dbname in all your pg_autoctl create command lines. Or upgrade to the new main branch when the linked PR #956 has been merged, later today.