zalando / patroni

A template for PostgreSQL High Availability with Etcd, Consul, ZooKeeper, or Kubernetes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pyinstaller bundled patroni started with multiprocessing-fork error

XiuhuaRuan opened this issue · comments

What happened?

When started patroni bundled by pyinstaller , it reported below multiprocessing related error.

usage: patroni [-h] [--version] [--validate-config] [configfile]
patroni: error: unrecognized arguments: --multiprocessing-fork pipe_handle=11

How can we reproduce it (as minimally and precisely as possible)?

  1. Execute mkbinary in source code to reproduce a patroni binary
  2. Starting the patroni binary could reproduce it

What did you expect to happen?

Starting patroni should succeed without error.

Patroni/PostgreSQL/DCS version

  • Patroni version: 3.1.0, 3.2.1
  • PostgreSQL version: 14.0
  • DCS (and its version): etcd3.5.9

Patroni configuration file

scope: postgres-cluster
namespace: /service/
name: postgres_01

restapi:
  listen: 192.168.61.105:8008
  connect_address: 192.168.61.105:8008

etcd:
  hosts: 192.168.61.105:2379,192.168.61.106:2379,192.168.61.107:2379

log:
  level: INFO
  traceback_level: INFO
  dir: /home/postgres/patroni
  file_num: 10
  file_size: 104857600

bootstrap:
  dcs:
    ttl: 30
    loop_wait: 10
    retry_timeout: 10
    maximum_lag_on_failover: 1048576
    master_start_timeout: 300
    synchronous_mode: false
    postgresql:
      use_pg_rewind: true
      parameters:
        listen_addresses: "*"
        port: 5432
        wal_level: replica
        hot_standby: "on"
        wal_keep_size: 100
        max_wal_senders: 10
        max_replication_slots: 10
        wal_log_hints: "on"
        archive_mode: "off"
        archive_timeout: 1800s
        logging_collector: on
        log_destination: 'stderr'
        log_truncate_on_rotation: on
        log_checkpoints: on
        log_connections: on
        log_disconnections: on
        log_error_verbosity: default
        log_lock_waits: on
        log_temp_files: 0
        log_autovacuum_min_duration: 0
        log_min_duration_statement: 50
        log_timezone: 'PRC'
        log_filename: postgresql-%Y-%m-%d_%H.log
        log_line_prefix: '%t [%p]: db=%d,user=%u,app=%a,client=%h '


postgresql:
  database: postgres
  listen: 0.0.0.0:5432
  connect_address: 192.168.61.105:5432
  bin_dir: /usr/local/pgsql/bin
  data_dir: /usr/local/pgsql/data
  pgpass: /home/postgres/tmp/.pgpass

  authentication:
    replication:
      username: postgres
      password: postgres
    superuser:
      username: postgres
      password: postgres
    rewind:
      username: postgres
      password: postgres

  pg_hba:
  - local   all             all                                     trust
  - host    all             all             0.0.0.0/0               trust
  - host    all             all             ::1/128                 trust
  - local   replication     all                                     trust
  - host    replication     all             0.0.0.0/0               trust
  - host    replication     all             ::1/128                 trust

tags:
    nofailover: false
    noloadbalance: false
    clonefrom: false
    nosync: false

patronictl show-config

NA.

Patroni log files

patroni starting log:
./patroni /home/postgres/patroni/patroni.yml
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Shanghai
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

usage: patroni [-h] [--version] [--validate-config] [configfile]
patroni: error: unrecognized arguments: --multiprocessing-fork pipe_handle=11



patroni.log:
2023-12-28 14:24:02,574 INFO: Selected new etcd server http://192.168.61.105:2379
2023-12-28 14:24:02,577 WARNING: postgresql parameter listen_addresses=* failed validation, defaulting to None
2023-12-28 14:24:02,577 WARNING: postgresql parameter port=5432 failed validation, defaulting to None
2023-12-28 14:24:02,577 INFO: No PostgreSQL configuration items changed, nothing to reload.
2023-12-28 14:24:02,584 INFO: Lock owner: None; I am postgres_01
2023-12-28 14:24:02,589 INFO: trying to bootstrap a new cluster
2023-12-28 14:24:12,581 INFO: Lock owner: None; I am postgres_01
2023-12-28 14:24:12,581 INFO: not healthy enough for leader race
2023-12-28 14:24:12,584 INFO: bootstrap in progress
2023-12-28 14:24:22,582 INFO: Lock owner: None; I am postgres_01
2023-12-28 14:24:22,582 INFO: not healthy enough for leader race
2023-12-28 14:24:22,585 INFO: bootstrap in progress
2023-12-28 14:24:32,580 INFO: Lock owner: None; I am postgres_01
2023-12-28 14:24:32,580 INFO: not healthy enough for leader race
2023-12-28 14:24:32,582 INFO: bootstrap in progress
2023-12-28 14:24:42,580 INFO: Lock owner: None; I am postgres_01
2023-12-28 14:24:42,580 INFO: not healthy enough for leader race
2023-12-28 14:24:42,583 INFO: bootstrap in progress
2023-12-28 14:24:52,580 INFO: Lock owner: None; I am postgres_01
2023-12-28 14:24:52,580 INFO: not healthy enough for leader race
2023-12-28 14:24:52,584 INFO: bootstrap in progress

PostgreSQL log files

NA.

Have you tried to use GitHub issue search?

  • Yes

Anything else we need to know?

I found a similar issue #1441 and that issue had been fixed long time ago. There is no such issue on patroni v3.0.0. I'm not sure which change makes this issue occur again since patroni v3.1.0. But considering the general solution, we could call freeze_support() straight after the if name == 'main' line of the main module to run the frozen executable safely. I will submit a PR for this issue.