cybertec-postgresql / patroni-windows-packaging

Automate installing and launching of Patroni under Windows
Other
15 stars 7 forks source link

Error Password when Run Patroni Service #67

Closed RendyH97 closed 7 months ago

RendyH97 commented 9 months ago

What Happened?

There are error on patroni when i run the patroni service like below: Patroni Log

2023-11-29 11:00:57,607 INFO: Selected new etcd server http://192.168.20.5:2379
2023-11-29 11:00:57,624 INFO: No PostgreSQL configuration items changed, nothing to reload.
2023-11-29 11:00:57,653 INFO: Lock owner: None; I am *name of patroni cluster
2023-11-29 11:00:57,673 INFO: trying to bootstrap a new cluster
2023-11-29 11:01:07,633 INFO: Lock owner: None; I am *name of patroni cluster
2023-11-29 11:01:07,633 INFO: not healthy enough for leader race
2023-11-29 11:01:07,653 INFO: bootstrap in progress
initdb: warning: enabling "trust" authentication for local connections
initdb: hint: 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.
2023-11-29 11:01:09,386 INFO: postmaster pid=6732
2023-11-29 11:01:09.546 +07 [6732] LOG:  redirecting log output to logging collector process
2023-11-29 11:01:09.546 +07 [6732] HINT:  Future log output will appear in directory "log".
2023-11-29 11:01:11,604 INFO: establishing a new patroni connection to the postgres cluster
2023-11-29 11:01:12,679 INFO: running post_bootstrap
2023-11-29 11:01:12,681 ERROR: post_bootstrap
Traceback (most recent call last):
  File "C:\PES\patroni\patroni\postgresql\bootstrap.py", line 384, in post_bootstrap
    self.create_or_update_role(superuser['username'], superuser['password'], ['SUPERUSER'])
  File "C:\PES\patroni\patroni\postgresql\bootstrap.py", line 372, in create_or_update_role
    self._postgresql.query(sql)
  File "C:\PES\patroni\patroni\postgresql\__init__.py", line 357, in query
    return self.retry(self._query, sql, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\PES\patroni\patroni\utils.py", line 599, in __call__
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\PES\patroni\patroni\postgresql\__init__.py", line 348, in _query
    raise e
  File "C:\PES\patroni\patroni\postgresql\__init__.py", line 337, in _query
    cursor.execute(sql.encode('utf-8'), params or None)
psycopg2.errors.SyntaxError: syntax error at or near "N"
LINE 8: ...TE ROLE "postgres" WITH SUPERUSER LOGIN PASSWORD 'N@makamu99...
                                                             ^

2023-11-29 11:01:12,684 INFO: removing initialize key after failed attempt to bootstrap the cluster
2023-11-29 11:01:12,759 INFO: renaming data directory to D:/PES/pgsql/data.failed
Traceback (most recent call last):
  File "C:\PES\patroni\patroni.py", line 6, in <module>
    main()
  File "C:\PES\patroni\patroni\__main__.py", line 191, in main
    return patroni_main(args.configfile)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\PES\patroni\patroni\__main__.py", line 162, in patroni_main
    abstract_main(Patroni, configfile)
  File "C:\PES\patroni\patroni\daemon.py", line 174, in abstract_main
    controller.run()
  File "C:\PES\patroni\patroni\__main__.py", line 133, in run
    super(Patroni, self).run()
  File "C:\PES\patroni\patroni\daemon.py", line 143, in run
    self._run_cycle()
  File "C:\PES\patroni\patroni\__main__.py", line 136, in _run_cycle
    logger.info(self.ha.run_cycle())
                ^^^^^^^^^^^^^^^^^^^
  File "C:\PES\patroni\patroni\ha.py", line 1871, in run_cycle
    info = self._run_cycle()
           ^^^^^^^^^^^^^^^^^
  File "C:\PES\patroni\patroni\ha.py", line 1684, in _run_cycle
    return self.post_bootstrap()
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\PES\patroni\patroni\ha.py", line 1568, in post_bootstrap
    self.cancel_initialization()
  File "C:\PES\patroni\patroni\ha.py", line 1561, in cancel_initialization
    raise PatroniFatalException('Failed to bootstrap cluster')
patroni.exceptions.PatroniFatalException: Failed to bootstrap cluster 

Postgre SQL Log

2023-11-29 11:01:09.546 +07 [6732] LOG:  starting PostgreSQL 16.0, compiled by Visual C++ build 1935, 64-bit
2023-11-29 11:01:09.548 +07 [6732] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-11-29 11:01:09.691 +07 [4572] LOG:  database system was shut down at 2023-11-29 11:01:01 +07
2023-11-29 11:01:09.740 +07 [6732] LOG:  database system is ready to accept connections
2023-11-29 11:01:12.681 +07 [6316] ERROR:  syntax error at or near "N" at character 290
2023-11-29 11:01:12.713 +07 [6732] LOG:  received immediate shutdown request
2023-11-29 11:01:12.748 +07 [6732] LOG:  database system is shut down

How can we reproduce it ?

  1. Download patroni package version v230925
  2. Install python, library python, create user, set firewall and set permission based on install.ps1 file
  3. Configure and Installation ETCD as usual
  4. ETCD Cluster success to installed and after check with this command => etcdctl endpoint health -w table --cluster all member is healthy
  5. Prepare patroni.yaml
  6. Install and start patroni service
  7. Check error log to C:\PES\patroni\log

patroni.yaml

scope: scope-name-example
namespace: /service/
name: name-example

restapi:
  listen: 0.0.0.0:8008
  connect_address: 192.168.20.5:8008

etcd3:
  hosts:
  - 192.168.20.4:2379
  - 192.168.20.5:2379
  - 192.168.20.6:2379

bootstrap:
  dcs:
    ttl: 30
    loop_wait: 10
    retry_timeout: 10
    maximum_lag_on_failover: 1048906
    postgresql:
      use_pg_rewind: true
      use_slots: true
      parameters:
        logging_collector: true
        log_directory: log
        log_filename: postgresql.log
        wal_keep_segments: 50
      pg_hba:
      - host replication replicator 0.0.0.0/0 md5
      - host all all 0.0.0.0/0 md5

  initdb: 
  - encoding: UTF8
  - data-checksums

postgresql:
  listen: 0.0.0.0:5432
  connect_address: 192.168.20.5:5432
  data_dir: D:/PES/pgsql/data
  bin_dir: C:/PES/pgsql/bin
  authentication:
    replication:
      username: replicator
      password: N@makamu99$$
    superuser:
      username: postgres
      password: N@makamu99$$

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

What did you expect to happen?

  1. Run Patroni Service successfuly
  2. Can use password with special characters like @ and etc

Patroni/PostgreSQL/DCS version

Release v230925 : https://github.com/cybertec-postgresql/patroni-windows-packaging/releases/tag/v230925 PYTHON | 3.11.5 ETCD | 3.5.9 PATRONI | 3.1.1 MICRO | 2.0.12 WINSW | 2.12.0 VIPMGR | 2.1.0 PGSQL | 16.0 PES GUI | 0.2

Anything else we need to know?

If you need any other information, please let me know. Thank you very much.

RendyH97 commented 9 months ago

Hi @pashagolub

Thank you for considering this issue as a bug. I would like to confirm, will there be any bug fixes in the near future regarding this issue?

Thank you very much

pashagolub commented 9 months ago

Hello,

It's on my to do list at the moment. However, I'm under heavy load, so cannot promise you any time frame.

Of course, we welcome any pull requests should you decide to tackle the issue.

Best regards

RendyH97 commented 9 months ago

Hi @pashagolub

Thank you very much for confirmation.

Currently, this issue is not a big obstacle for us. We can still use other strong passwords. So it doesn't matter if it can't be fixed in the near future.

I don't think I have the expertise to fix these bugs yet. So I'm just waiting for a bug fix at the moment.

Thank you very much for your help. Appreciate it. Warm Regards

pashagolub commented 7 months ago

Sorry for such a delay. After thorough investigation I can confirm this is the issue with patroni itself and not with Windows installation this repo is providing.

If you still experience this issue, please, consider to file a ticket to the patroni project.

Best regards

RendyH97 commented 7 months ago

Hi @pashagolub Thank you for information and for checking this password Issue.

Warm Regards