mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Start postgres with hot_standby=off when doing PITR (#1788)
When doing a custom bootstrap the configured value of max_connections could be smaller than the actual value stored in the pg_contol. As a workaround Patroni already did an adjustment of such parameters. Unfortunately, it doesn't cover the case when the parameter value was increased even higher during the WAL replay. That was causing postgres to stop. The hot_standby=off disable connections to the instance, but allows postgres to run with parameter values smaller than required. The hot_standby=off doesn't affect the running primary. When the recovery finishes and postgres promotes it starts accepting connections as usual. If the node will be demoted, Patroni will stop postgres and start it up as replica with hot_standby=on.
This commit is contained in:
@@ -387,6 +387,11 @@ class ConfigHandler(object):
|
||||
if 'custom_conf' not in self._config and not os.path.exists(self._postgresql_base_conf):
|
||||
os.rename(self._postgresql_conf, self._postgresql_base_conf)
|
||||
|
||||
# In case we are using custom bootstrap from spilo image with PITR it fails if it contains increasing
|
||||
# values like Max_connections. We disable hot_standby so it will accept increasing values.
|
||||
if self._postgresql.bootstrap.running_custom_bootstrap:
|
||||
configuration['hot_standby'] = 'off'
|
||||
|
||||
with ConfigWriter(self._postgresql_conf) as f:
|
||||
include = self._config.get('custom_conf') or self._postgresql_base_conf_name
|
||||
f.writeline("include '{0}'\n".format(ConfigWriter.escape(include)))
|
||||
|
||||
Reference in New Issue
Block a user