patroni.postgresql.config module¶
-
class
patroni.postgresql.config.
ConfigHandler
(postgresql: Postgresql, config: Dict[str, Any])¶ Bases:
object
-
CMDLINE_OPTIONS
= <CaseInsensitiveDict{'listen_addresses': (None, <function _false_validator>, 90100), 'port': (None, <function _false_validator>, 90100), 'cluster_name': (None, <function _false_validator>, 90500), 'wal_level': ('hot_standby', <patroni.validator.EnumValidator object>, 90100), 'hot_standby': ('on', <function _bool_is_true_validator>, 90100), 'max_connections': (100, <patroni.validator.IntValidator object>, 90100), 'max_wal_senders': (10, <patroni.validator.IntValidator object>, 90100), 'wal_keep_segments': (8, <patroni.validator.IntValidator object>, 90100), 'wal_keep_size': ('128MB', <patroni.validator.IntValidator object>, 130000), 'max_prepared_transactions': (0, <patroni.validator.IntValidator object>, 90100), 'max_locks_per_transaction': (64, <patroni.validator.IntValidator object>, 90100), 'track_commit_timestamp': ('off', <function _bool_validator>, 90500), 'max_replication_slots': (10, <patroni.validator.IntValidator object>, 90400), 'max_worker_processes': (8, <patroni.validator.IntValidator object>, 90400), 'wal_log_hints': ('on', <function _bool_is_true_validator>, 90400)} at 7fe971b10250>¶
-
build_recovery_params
(member: Optional[Union[patroni.dcs.Leader, patroni.dcs.Member]]) → patroni.collections.CaseInsensitiveDict¶
-
check_recovery_conf
(member: Optional[Union[patroni.dcs.Leader, patroni.dcs.Member]]) → Tuple[bool, bool]¶ Returns a tuple. The first boolean element indicates that recovery params don’t match and the second is set to True if the restart is required in order to apply new values
-
property
config_dir
¶
-
config_writer
(filename: str) → Iterator[patroni.postgresql.config.ConfigWriter]¶ Create
ConfigWriter
object and set permissions on a filename.- Parameters
filename – path to a config file.
- Yields
ConfigWriter
object.
-
property
effective_configuration
¶ It might happen that the current value of one (or more) below parameters stored in the controldata is higher than the value stored in the global cluster configuration.
Example: max_connections in global configuration is 100, but in controldata Current max_connections setting: 200. If we try to start postgres with max_connections=100, it will immediately exit. As a workaround we will start it with the values from controldata and set pending_restart to true as an indicator that current values of parameters are not matching expectations.
-
get_server_parameters
(config: Dict[str, Any]) → patroni.collections.CaseInsensitiveDict¶
-
property
hba_file
¶
-
property
ident_file
¶
-
property
local_connect_kwargs
¶
-
property
pg_hba_conf
¶
-
property
postgresql_conf
¶
-
primary_conninfo_params
(member: Optional[Union[patroni.dcs.Leader, patroni.dcs.Member]]) → Optional[Dict[str, Any]]¶
-
replace_pg_hba
() → Optional[bool]¶ Replace pg_hba.conf content in the PGDATA if hba_file is not defined in the postgresql.parameters and pg_hba is defined in postgresql configuration section.
- Returns
True if pg_hba.conf was rewritten.
-
replace_pg_ident
() → Optional[bool]¶ Replace pg_ident.conf content in the PGDATA if ident_file is not defined in the postgresql.parameters and pg_ident is defined in the postgresql section.
- Returns
True if pg_ident.conf was rewritten.
-
property
replication
¶
-
property
rewind_credentials
¶
-
save_configuration_files
(check_custom_bootstrap: bool = False) → bool¶ copy postgresql.conf to postgresql.conf.backup to be able to retrieve configuration files - originally stored as symlinks, those are normally skipped by pg_basebackup - in case of WAL-E basebackup (see http://comments.gmane.org/gmane.comp.db.postgresql.wal-e/239)
-
set_file_permissions
(filename: str) → None¶ Set permissions of file filename according to the expected permissions if it resides under PGDATA.
Note
Do nothing if the file is not under PGDATA.
- Parameters
filename – path to a file which permissions might need to be adjusted.
-
set_synchronous_standby_names
(value: Optional[str]) → Optional[bool]¶ Updates synchronous_standby_names and reloads if necessary. :returns: True if value was updated.
-
property
superuser
¶
-
property
triggerfile_good_name
¶
-
write_postgresql_conf
(configuration: Optional[patroni.collections.CaseInsensitiveDict] = None) → None¶
-
write_recovery_conf
(recovery_params: patroni.collections.CaseInsensitiveDict) → None¶
-
-
patroni.postgresql.config.
parse_dsn
(value: str) → Optional[Dict[str, str]]¶ Very simple equivalent of psycopg2.extensions.parse_dsn introduced in 2.7.0. We are not using psycopg2 function in order to remain compatible with 2.5.4+. There is one minor difference though, this function removes dbname from the result and sets the sslmode, ‘gssencmode’, and channel_binding to prefer if it is not present in the connection string. This is necessary to simplify comparison of the old and the new values.
>>> r = parse_dsn('postgresql://u%2Fse:pass@:%2f123,[::1]/db%2Fsdf?application_name=mya%2Fpp&ssl=true') >>> r == {'application_name': 'mya/pp', 'host': ',::1', 'sslmode': 'require', 'password': 'pass', 'port': '/123,', 'user': 'u/se', 'gssencmode': 'prefer', 'channel_binding': 'prefer'} True >>> r = parse_dsn(" host = 'host' dbname = db\\ name requiressl=1 ") >>> r == {'host': 'host', 'sslmode': 'require', 'gssencmode': 'prefer', 'channel_binding': 'prefer'} True >>> parse_dsn('requiressl = 0\\') == {'sslmode': 'prefer', 'gssencmode': 'prefer', 'channel_binding': 'prefer'} True >>> parse_dsn("host=a foo = '") is None True >>> parse_dsn("host=a foo = ") is None True >>> parse_dsn("1") is None True
-
patroni.postgresql.config.
read_recovery_param_value
(value: str) → Optional[str]¶ >>> read_recovery_param_value('') is None True >>> read_recovery_param_value("'") is None True >>> read_recovery_param_value("''a") is None True >>> read_recovery_param_value('a b') is None True >>> read_recovery_param_value("'''") is None True >>> read_recovery_param_value("'\\") is None True >>> read_recovery_param_value("'a' s#") is None True >>> read_recovery_param_value("'\\'''' #a") "''" >>> read_recovery_param_value('asd') 'asd'