diff --git a/postgres-appliance/major_upgrade/inplace_upgrade.py b/postgres-appliance/major_upgrade/inplace_upgrade.py index 2d4ade477..6fa9e31f5 100644 --- a/postgres-appliance/major_upgrade/inplace_upgrade.py +++ b/postgres-appliance/major_upgrade/inplace_upgrade.py @@ -529,10 +529,7 @@ def do_upgrade(self): if self.replica_connections: from patroni.postgresql.misc import parse_lsn - # Make sure we use the pg_controldata from the correct major version - self.postgresql.set_bin_dir(self.cluster_version) controldata = self.postgresql.controldata() - self.postgresql.set_bin_dir(self.desired_version) checkpoint_lsn = controldata.get('Latest checkpoint location') if controldata.get('Database cluster state') != 'shut down' or not checkpoint_lsn: diff --git a/postgres-appliance/major_upgrade/pg_upgrade.py b/postgres-appliance/major_upgrade/pg_upgrade.py index dee894b99..a5f51ba49 100644 --- a/postgres-appliance/major_upgrade/pg_upgrade.py +++ b/postgres-appliance/major_upgrade/pg_upgrade.py @@ -35,7 +35,9 @@ def restore_shared_preload_libraries(self): return True def start_old_cluster(self, config, version): + self._new_bin_dir = self._bin_dir self.set_bin_dir(version) + self._old_bin_dir = self._bin_dir # make sure we don't archive wals from the old version self._old_config_values = {'archive_mode': self.config.get('parameters').get('archive_mode')} @@ -53,7 +55,6 @@ def get_cluster_version(self): def set_bin_dir(self, version): from spilo_commons import get_bin_dir - self._old_bin_dir = self._bin_dir self._bin_dir = get_bin_dir(version) @property @@ -168,7 +169,7 @@ def pg_upgrade(self, check=False): os.chdir(upgrade_dir) pg_upgrade_args = ['-k', '-j', str(psutil.cpu_count()), - '-b', self._old_bin_dir, '-B', self._bin_dir, + '-b', self._old_bin_dir, '-B', self._new_bin_dir, '-d', self._data_dir, '-D', self._new_data_dir, '-O', "-c timescaledb.restoring='on'", '-O', "-c archive_mode='off'"] @@ -180,8 +181,12 @@ def pg_upgrade(self, check=False): else: self.config.write_postgresql_conf() + self._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 os.chdir(old_cwd) shutil.rmtree(upgrade_dir) return True @@ -206,7 +211,9 @@ def prepare_new_pgdata(self, version): old_version_file = self._version_file self._version_file = os.path.join(self._data_dir, 'PG_VERSION') + self._old_bin_dir = self._bin_dir self.set_bin_dir(version) + self._new_bin_dir = self._bin_dir # shared_preload_libraries for the old cluster, cleaned from incompatible/missing libs old_shared_preload_libraries = self.config.get('parameters').get('shared_preload_libraries') @@ -239,6 +246,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 if old_shared_preload_libraries: self.config.get('parameters')['shared_preload_libraries'] = old_shared_preload_libraries diff --git a/postgres-appliance/tests/docker-compose.yml b/postgres-appliance/tests/docker-compose.yml index a2b86e016..48b5ef277 100644 --- a/postgres-appliance/tests/docker-compose.yml +++ b/postgres-appliance/tests/docker-compose.yml @@ -46,6 +46,7 @@ services: postgresql: parameters: wal_keep_segments: 8 + jit: 'off' postgresql: parameters: shared_buffers: 32MB