Package: patroni
Version: 4.0.4-5
Control: fixed -1 2.0.2-1
Control: fixed -1 2.1.1-1
Control: found -1 2.1.2-1
Control: found -1 2.1.5-1
Control: found -1 3.2.1-1
Control: found -1 3.3.4-1
Control: found -1 3.3.5-1

Since patroni 2.1.2-1, "patronictl reinit" no longer works on my clusters. When I try it, I get a sequence of log messages like this:

2025-01-28T15:24:24.429074+00:00 UIS-moa-dev-debian3 patroni@15-main[60182]: 
2025-01-28 15:24:24,428 INFO: Removing data directory: 
/var/lib/postgresql/15/main
2025-01-28T15:24:34.365870+00:00 UIS-moa-dev-debian3 patroni@15-main[60182]: 
2025-01-28 15:24:34,362 INFO: Lock owner: moa-dev-debian1; I am moa-dev-debian3
2025-01-28T15:24:34.365922+00:00 UIS-moa-dev-debian3 patroni@15-main[60182]: 
2025-01-28 15:24:34,365 INFO: trying to bootstrap from leader 'moa-dev-debian1'
2025-01-28T15:24:34.400036+00:00 UIS-moa-dev-debian3 patroni@15-main[60800]: 
Use of uninitialized value $data_directory in concatenation (.) or string at 
/usr/share/perl5/PgCommon.pm line 284.
2025-01-28T15:24:34.400379+00:00 UIS-moa-dev-debian3 patroni@15-main[60800]: 
Use of uninitialized value $data_directory in concatenation (.) or string at 
/usr/share/perl5/PgCommon.pm line 284.
2025-01-28T15:24:34.400687+00:00 UIS-moa-dev-debian3 patroni@15-main[60800]: 
Use of uninitialized value $data_directory in concatenation (.) or string at 
/usr/share/perl5/PgCommon.pm line 284.
2025-01-28T15:24:34.400787+00:00 UIS-moa-dev-debian3 patroni@15-main[60800]: 
Error: Invalid data directory for cluster 15 main
2025-01-28T15:24:34.431660+00:00 UIS-moa-dev-debian3 patroni@15-main[60801]: 
Error: cluster configuration already exists
2025-01-28T15:24:34.432757+00:00 UIS-moa-dev-debian3 patroni@15-main[60182]: 
2025-01-28 15:24:34,432 ERROR: Error creating replica using method 
pg_clonecluster: /usr/share/patroni/pg_clonecluster_patroni exited with code=1
2025-01-28T15:24:34.432794+00:00 UIS-moa-dev-debian3 patroni@15-main[60182]: 
2025-01-28 15:24:34,432 ERROR: failed to bootstrap from leader 'moa-dev-debian1'
2025-01-28T15:24:34.432809+00:00 UIS-moa-dev-debian3 patroni@15-main[60182]: 
2025-01-28 15:24:34,432 INFO: Removing data directory: 
/var/lib/postgresql/15/main

I initially ran into this problem using the PGDG package of Patroni on Ubuntu 20.04 LTS, but I have reproduced it using sid snapshots between 2021 and 2024.

A workaround is to remove the configuration directory under /etc/postgresql (e.g. "rm -r /etc/postgresql/17/main). If I do that, then Patroni is able to re-initialise the node once, but the next attempt will fail.

It seems unlikely that re-initialisation has actually been broken in the Debian Patroni package for three years, so I think it's likely there's something wrong with my configuration, but I can't work out what.

Here is my Patroni configuration, /etc/patroni/15-main.yml, with the passwords removed:

scope: "15-main"
namespace: "/postgresql-common/"
name: "moa-dev-debian3"

etcd:
  host: 127.0.0.1:2379

restapi:
  listen: :::8008
  connect_address: 10.136.3.45:8008
  certfile: /etc/moa-tls/patroni.crt
  keyfile: /etc/moa-tls/patroni.key
  cafile: /etc/moa-tls/ca/ca.crt
  verify_client: optional

ctl:
  cacert: /etc/moa-tls/ca/ca.crt
  certfile: /etc/moa-tls/patroni.crt
  keyfile: /etc/moa-tls/patroni.key

bootstrap:
  # Custom bootstrap method
  method: pg_createcluster
  pg_createcluster:
    command: /usr/share/patroni/pg_createcluster_patroni
  post_init: /etc/patroni/post-init

  # this section will be written into Etcd:/<namespace>/<scope>/config after 
initializing new cluster
  # and all other cluster members will use it as a `global configuration`
  dcs: {"ttl": 30, "loop_wait": 10, "retry_timeout": 10, "master_stop_timeout": 30, "maximum_lag_on_failover": 1048576, "synchronous_mode": true, "postgresql": {"use_pg_rewind": false, "remove_data_directory_on_rewind_failure": true, "remove_data_directory_on_diverged_timelines": true, "use_slots": false, "parameters": 
{"ssl_cert_file": "/etc/moa-tls/postgresql.crt", "ssl_key_file": "/etc/moa-tls/postgresql.key", "ssl_min_protocol_version": "TLSv1", "password_encryption": "scram-sha-256", "wal_level": "logical", "log_connections": true, "log_disconnections": true, "log_destination": "syslog", 
"log_min_messages": "log", "logging_collector": false, "shared_buffers": "256MB"}, "pg_hba": ["local      all,replication  all                  peer map=local", "hostssl    replication      moa_replicator  all  scram-sha-256", "hostssl    postgres         moa_rewind      all  scram-sha-256", "hostssl    all,replication  all             all  
md5", "hostnossl  all,replication  +moa_nossl      all
  md5"], "pg_ident": ["local root moa_superuser", "local postgres moa_superuser", "local postgres 
moa_replicator", "local postgres moa_rewind", "local root moa_collectd", "local dump moa_superuser"]}}

postgresql:
  # Custom clone method
  create_replica_method:
    - pg_clonecluster
  pg_clonecluster:
    command: /usr/share/patroni/pg_clonecluster_patroni

  # Listen on all local addresses.  Note that Patroni extracts the port
  # number by looking for the last ':', so the IPv6 address won't
  # confuse it.
  listen: "::,0.0.0.0:5432"
  connect_address: 10.136.3.45:5432
  use_unix_socket: true
  data_dir: /var/lib/postgresql/15/main
  bin_dir: /usr/lib/postgresql/15/bin
  config_dir: /etc/postgresql/15/main
  pgpass: /var/lib/postgresql/15-main.pgpass
  authentication:
    replication:
      username: moa_replicator
      password: "<secret>"
      sslmode: verify-ca
    rewind:
      username: moa_rewind
      password: "<secret>"
      sslmode: verify-ca
# A superuser role is required in order for Patroni to manage the local
# Postgres instance.  If the option `use_unix_socket' is set to `true', then
# specifying an empty password results in no md5 password for the superuser
# being set and sockets being used for authentication. The `password:' line is
# nevertheless required.  Note that pg_rewind will not work if no md5 password
# is set.
    superuser:
      username: moa_superuser
      password:


--
Ben Harris, University of Cambridge Information Services.

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.1.0-29-amd64 (SMP w/1 CPU thread; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages patroni depends on:
ii  python3                        3.11.2-1+b1
ii  python3-cdiff                  1.4.2-1
ii  python3-click                  8.1.7-2
ii  python3-dateutil               2.9.0-3
ii  python3-etcd                   0.4.5-6
ii  python3-pkg-resources          75.6.0-1
ii  python3-prettytable            3.12.0-1
ii  python3-psutil                 5.9.8-2
ii  python3-psycopg2               2.9.5-1+b1
ii  python3-urllib3                2.2.3-4
ii  python3-yaml                   6.0-3+b2
ii  python3-ydiff [python3-cdiff]  1.4.2-1

Versions of packages patroni recommends:
ii  iproute2  6.1.0-3

Versions of packages patroni suggests:
ii  etcd-server  3.5.16-3
pn  haproxy      <none>
pn  patroni-doc  <none>
pn  postgresql   <none>
pn  vip-manager  <none>

-- no debconf information

Reply via email to