From db12051a5b98391c55dbcb2a1305ed08b73e450c Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Tue, 17 Aug 2021 16:14:10 +0200 Subject: [PATCH] Improve compatibility with latest minor releases (#2034) The commit https://github.com/postgres/postgres/commit/93a0bf2390327a482ff37317f6e17547e735409e changed the behavior of `pg_settings.pending_restart`. Mostly it will not cause issues because usually people very rarely removing values from the config, but one case is unique. If Patroni is restarted for an upgrade and it finds that Postgres is up and running, it rewrites `postgresql.conf` and performs a reload. As a result, recovery parameters are removed from the config for Postgres v12+ and the `pending_restart` flag is falsely set. In order to partially mitigate the problem before it is fixed in Postgres we will skip recovery parameters when checking `pending_restart` flags in the `pg_settings`. In addition to that, remove two parameters from the validator because they were reverted from Postgres v14. --- patroni/postgresql/config.py | 5 +++-- patroni/postgresql/validator.py | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/patroni/postgresql/config.py b/patroni/postgresql/config.py index 8cae0dfb..46c3991d 100644 --- a/patroni/postgresql/config.py +++ b/patroni/postgresql/config.py @@ -1001,8 +1001,9 @@ class ConfigHandler(object): if self._postgresql.major_version >= 90500: time.sleep(1) try: - pending_restart = self._postgresql.query('SELECT COUNT(*) FROM pg_catalog.pg_settings' - ' WHERE pending_restart').fetchone()[0] > 0 + pending_restart = self._postgresql.query( + 'SELECT COUNT(*) FROM pg_catalog.pg_settings WHERE pg_catalog.lower(name) != ALL(%s)' + ' AND pending_restart', [n.lower() for n in self._RECOVERY_PARAMETERS]).fetchone()[0] > 0 self._postgresql.set_pending_restart(pending_restart) except Exception as e: logger.warning('Exception %r when running query', e) diff --git a/patroni/postgresql/validator.py b/patroni/postgresql/validator.py index 945d5afd..5da6d1b3 100644 --- a/patroni/postgresql/validator.py +++ b/patroni/postgresql/validator.py @@ -170,7 +170,6 @@ parameters = CaseInsensitiveDict({ 'DateStyle': String(90300, None), 'db_user_namespace': Bool(90300, None), 'deadlock_timeout': Integer(90300, None, 1, 2147483647, 'ms'), - 'debug_invalidate_system_caches_always': Integer(140000, None, '0', '0', None), 'debug_pretty_print': Bool(90300, None), 'debug_print_parse': Bool(90300, None), 'debug_print_plan': Bool(90300, None), @@ -208,7 +207,6 @@ parameters = CaseInsensitiveDict({ 'enable_partition_pruning': Bool(110000, None), 'enable_partitionwise_aggregate': Bool(110000, None), 'enable_partitionwise_join': Bool(110000, None), - 'enable_resultcache': Bool(140000, None), 'enable_seqscan': Bool(90300, None), 'enable_sort': Bool(90300, None), 'enable_tidscan': Bool(90300, None),