Skip to content

Commit

Permalink
Adapt for the newer Patroni versions
Browse files Browse the repository at this point in the history
Patroni caches available GUCs since 3.2.1
  • Loading branch information
hughcapet committed Jan 26, 2024
1 parent a89ca13 commit 42e0ffd
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions postgres-appliance/major_upgrade/pg_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def restore_shared_preload_libraries(self):

def start_old_cluster(self, config, version):
self._new_bin_dir = self._bin_dir
self.set_bin_dir(version)
self.set_bin_dir_for_version(version)
self._old_bin_dir = self._bin_dir

# make sure we don't archive wals from the old version
Expand All @@ -52,10 +52,15 @@ def get_cluster_version(self):
with open(self._version_file) as f:
return f.read().strip()

def set_bin_dir(self, version):
def set_bin_dir_for_version(self, version):
from spilo_commons import get_bin_dir

self._bin_dir = get_bin_dir(version)
self._available_gucs = None

def set_bin_dir(self, bin_dir):
self._bin_dir = bin_dir
self._available_gucs = None

@property
def local_conn_kwargs(self):
Expand Down Expand Up @@ -181,12 +186,12 @@ def pg_upgrade(self, check=False):
else:
self.config.write_postgresql_conf()

self._bin_dir = self._new_bin_dir
self.set_bin_dir(self._new_bin_dir)

logger.info('Executing pg_upgrade%s', (' --check' if check else ''))
if subprocess.call([self.pgcommand('pg_upgrade')] + pg_upgrade_args) == 0:
if check:
self._bin_dir = self._old_bin_dir
self.set_bin_dir(self._old_bin_dir)
os.chdir(old_cwd)
shutil.rmtree(upgrade_dir)
return True
Expand All @@ -212,7 +217,7 @@ def prepare_new_pgdata(self, version):
self._version_file = os.path.join(self._data_dir, 'PG_VERSION')

self._old_bin_dir = self._bin_dir
self.set_bin_dir(version)
self.set_bin_dir_for_version(version)
self._new_bin_dir = self._bin_dir

# shared_preload_libraries for the old cluster, cleaned from incompatible/missing libs
Expand Down Expand Up @@ -246,7 +251,7 @@ def prepare_new_pgdata(self, version):
self._new_data_dir, self._data_dir = self._data_dir, self._new_data_dir
self.config._postgresql_conf = old_postgresql_conf
self._version_file = old_version_file
self._bin_dir = self._old_bin_dir
self.set_bin_dir(self._old_bin_dir)

if old_shared_preload_libraries:
self.config.get('parameters')['shared_preload_libraries'] = old_shared_preload_libraries
Expand Down

0 comments on commit 42e0ffd

Please sign in to comment.