* debian/patches/pg_rewind_fix_get_guc_value.patch: New patch, changes the
pg_rewind calling behaviour so that it can deal with postgresql.conf not being in the data directory; taken from upstream commit 7626b5f by Nick Bluth.
This commit is contained in:
parent
b6215af13a
commit
2c599f9c46
5
debian/changelog
vendored
5
debian/changelog
vendored
|
@ -1,5 +1,10 @@
|
|||
patroni (2.1.3-2) UNRELEASED; urgency=medium
|
||||
|
||||
[ Michael Banck ]
|
||||
* debian/patches/pg_rewind_fix_get_guc_value.patch: New patch, changes the
|
||||
pg_rewind calling behaviour so that it can deal with postgresql.conf not
|
||||
being in the data directory; taken from upstream commit 7626b5f by Nick
|
||||
Bluth.
|
||||
|
||||
-- Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org> Fri, 18 Feb 2022 22:16:47 +0100
|
||||
|
||||
|
|
56
debian/patches/pg_rewind_fix_get_guc_value.patch
vendored
Normal file
56
debian/patches/pg_rewind_fix_get_guc_value.patch
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
commit 7626b5fef8ef18feab477354006a56b46a47436e
|
||||
Author: Gunnar "Nick" Bluth <gunnar.bluth@pro-open.de>
|
||||
Date: Thu Mar 24 13:56:16 2022 +0100
|
||||
|
||||
Fix pg_rewind on typical Debian/Ubuntu systems (#2225)
|
||||
|
||||
On Debian/Ubuntu systems it is common to keep Postgres config files outside of the data directory.
|
||||
It created a couple of problems for pg_rewind support in Patroni.
|
||||
1. The `--config_file` argument must be supplied while figuring out the `restore_command` GUC value on Postgres v12+
|
||||
2. With Postgres v13+ pg_rewind by itself can't find postgresql.conf in order to figure out `restore_command` and therefore we have to use Patroni as a fallback for fetching missing WAL's that are required for rewind.
|
||||
|
||||
This commit addresses both problems.
|
||||
|
||||
diff --git a/patroni/postgresql/__init__.py b/patroni/postgresql/__init__.py
|
||||
index aeadc3e..3b9f250 100644
|
||||
--- a/patroni/postgresql/__init__.py
|
||||
+++ b/patroni/postgresql/__init__.py
|
||||
@@ -798,7 +798,8 @@ class Postgresql(object):
|
||||
return True
|
||||
|
||||
def get_guc_value(self, name):
|
||||
- cmd = [self.pgcommand('postgres'), '-D', self._data_dir, '-C', name]
|
||||
+ cmd = [self.pgcommand('postgres'), '-D', self._data_dir, '-C', name,
|
||||
+ '--config-file={}'.format(self.config.postgresql_conf)]
|
||||
try:
|
||||
data = subprocess.check_output(cmd)
|
||||
if data:
|
||||
diff --git a/patroni/postgresql/rewind.py b/patroni/postgresql/rewind.py
|
||||
index fb754f5..5a2e4a3 100644
|
||||
--- a/patroni/postgresql/rewind.py
|
||||
+++ b/patroni/postgresql/rewind.py
|
||||
@@ -311,8 +311,14 @@ class Rewind(object):
|
||||
restore_command = self._postgresql.config.get('recovery_conf', {}).get('restore_command') \
|
||||
if self._postgresql.major_version < 120000 else self._postgresql.get_guc_value('restore_command')
|
||||
|
||||
+ # currently, pg_rewind expects postgresql.conf to be inside $PGDATA, which is not the case on e.g. Debian
|
||||
+ # Fix this logic if e.g. PG15 receives an update for pg_rewind:
|
||||
+ pg_rewind_can_restore = self._postgresql.major_version >= 130000 \
|
||||
+ and restore_command \
|
||||
+ and self._postgresql.config._config_dir == self._postgresql.data_dir
|
||||
+
|
||||
cmd = [self._postgresql.pgcommand('pg_rewind')]
|
||||
- if self._postgresql.major_version >= 130000 and restore_command:
|
||||
+ if pg_rewind_can_restore:
|
||||
cmd.append('--restore-target-wal')
|
||||
cmd.extend(['-D', self._postgresql.data_dir, '--source-server', dsn])
|
||||
|
||||
@@ -329,7 +335,7 @@ class Rewind(object):
|
||||
if ret == 0:
|
||||
return True
|
||||
|
||||
- if not restore_command or self._postgresql.major_version >= 130000:
|
||||
+ if not restore_command or pg_rewind_can_restore:
|
||||
return False
|
||||
|
||||
missing_wal = self._find_missing_wal(results['stderr']) or self._find_missing_wal(results['stdout'])
|
1
debian/patches/series
vendored
1
debian/patches/series
vendored
|
@ -4,3 +4,4 @@ requirements_setuptools.patch
|
|||
offline_intersphinx.patch
|
||||
requirements_cdiff.patch
|
||||
regression_tests_disable_raft_tests.py
|
||||
pg_rewind_fix_get_guc_value.patch
|
||||
|
|
Loading…
Reference in a new issue