From 4830e36e2b1002daa4c182ed1b4c07882268bbe5 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Thu, 20 Jul 2023 13:23:55 +0200 Subject: [PATCH 1/2] Start primary back when it crashed with "in crash recovery" state (#2763) If one of backends crashed postmaster stops all backend and does crash recovery because shared memory could be corrupted. If something happens during this phase postgres may completely crash leaving pg_control with "in crash recovery" state. Followup on #2726 --- patroni/ha.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/patroni/ha.py b/patroni/ha.py index 1148802a..f704500e 100644 --- a/patroni/ha.py +++ b/patroni/ha.py @@ -473,7 +473,8 @@ class Ha(object): # timeout > 0 indicates that we still have the leader lock, and it was just updated if timeout\ - and data.get('Database cluster state') in ('in production', 'shutting down', 'shut down')\ + and data.get('Database cluster state') in ('in production', 'in crash recovery', + 'shutting down', 'shut down')\ and self.state_handler.state == 'crashed'\ and self.state_handler.role in ('primary', 'master')\ and not self.state_handler.config.recovery_conf_exists(): From cb9998ade67b69adebf31b09364591c3230df4bb Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Thu, 20 Jul 2023 13:24:17 +0200 Subject: [PATCH 2/2] Update docstring in do_GET_metrics() (#2765) followup #2733 --- patroni/api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/patroni/api.py b/patroni/api.py index 836a8673..8d991d5f 100644 --- a/patroni/api.py +++ b/patroni/api.py @@ -463,6 +463,12 @@ class RestApiHandler(BaseHTTPRequestHandler): * ``patroni_dcs_last_seen``: epoch timestamp when DCS was last contacted successfully; * ``patroni_pending_restart``: ``1`` if this PostgreSQL node is pending a restart, else ``0``; * ``patroni_is_paused``: ``1`` if Patroni is in maintenance node, else ``0``. + + For PostgreSQL v9.6+ the response will also have the following: + + * ``patroni_postgres_streaming``: 1 if Postgres is streaming from another node, else ``0``; + * ``patroni_postgres_in_archive_recovery``: ``1`` if Postgres isn't streaming and + there is ``restore_command`` available, else ``0``. """ postgres = self.get_postgresql_status(True) patroni = self.server.patroni