patroni.postgresql.config module
- class _patroni.postgresql.config.ConfigHandler(_postgresql: Postgresql, config: Dict[ str, Any]) View on GitHub
-
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 7f8bcc0b9350>_
-
+
- RECOVERY_PARAMETERS = <CaseInsensitiveSet('archive_cleanup_command', 'pause_at_recovery_target', 'primary_conninfo', 'primary_slot_name', 'promote_trigger_file', 'recovery_end_command', 'recovery_min_apply_delay', 'recovery_target', 'recovery_target_action', 'recovery_target_inclusive', 'recovery_target_lsn', 'recovery_target_name', 'recovery_target_time', 'recovery_target_timeline', 'recovery_target_xid', 'restore_command', 'standby_mode', 'trigger_file') at 7f8bcc0b9290>_
-
+
- __init\\__(postgresql: Postgresql, config: Dict[ str, Any]) → None View on GitHub
-
+
- _adjust_recovery_parameters() → None View on GitHub
-
+
- check_passfile(_passfile: str, wanted_primary_conninfo: Dict[ str, Any]) → bool View on GitHub
-
+
- check_primary_conninfo(_primary_conninfo: Dict[ str, Any], wanted_primary_conninfo: Dict[ str, Any]) → bool View on GitHub
-
+
- property \\__configuration_to_save: List[ str]_
-
+
- get_pg_settings(_names: Collection[ str]) → Dict[ Any, Tuple[ Any, …]] View on GitHub
-
+
- _get_tcp_local_address() → str View on GitHub
-
+
- static \\__get_unix_local_address(_unix_socket_directories: str) → str View on GitHub
-
+
- static \\__handle_wal_buffers(_old_values: Dict[ Any, Tuple[ Any, …]], changes: CaseInsensitiveDict) → None View on GitHub
-
+
- static \\__pgpass_line(_record: Dict[ str, Any]) → str | None View on GitHub
-
+
- _read_recovery_params() → Tuple[CaseInsensitiveDict | None, bool] View on GitHub
-
Read current recovery parameters values. + Note
We query Postgres only if we detected that Postgresql was restarted or when at least one of the following files was updated:
\\__\\__ \\__\\__ + Returns::: a tuple with two elements: +
- _read_recovery_params_pre_v12() → Tuple[CaseInsensitiveDict | None, bool] View on GitHub
-
+
- property \\__recovery_parameters_to_compare: CaseInsensitiveSet_
-
+
- static \\__remove_file_if_exists(_name: str) → None View on GitHub
-
+
- _sanitize_auto_conf() → None View on GitHub
-
+
- property \\__triggerfile_wrong_name: str_
-
+
- write_recovery_params(_fd: ConfigWriter, recovery_params: CaseInsensitiveDict) → None View on GitHub
-
+
- append_pg_hba(config: List[ str]) → bool View on GitHub
-
+
- build_recovery_params(member: Leader | Member | None) → CaseInsensitiveDict View on GitHub
-
+
- check_directories() → None View on GitHub
-
+
- check_recovery_conf(member: Leader | Member | None) → Tuple[ bool, bool] View on GitHub
-
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: str_
-
+
- config_writer(filename: str) → Iterator[ConfigWriter] View on GitHub
-
Create
ConfigWriter
object and set permissions on a filename. +- Parameters
-
filename – path to a config file.
- Yields
-
ConfigWriter
object. +
- property _effective_configuration: CaseInsensitiveDict_
-
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. + - format_dsn(params: Dict[ str, Any], include_dbname: bool = False) → str View on GitHub
-
+
- get(key: str, default: Any | None = None) → Any | None View on GitHub
-
+
- get_server_parameters(config: Dict[ str, Any]) → CaseInsensitiveDict View on GitHub
-
+
- property _hba_file: str | None_
-
+
- property _ident_file: str | None_
-
+
- load_current_server_parameters() → None View on GitHub
-
Read GUC’s values from
pg_settings
when Patroni is joining the the postgres that is already running. + - property _pg_hba_conf: str_
-
+
- property _postgresql_conf: str_
-
+
- primary_conninfo_params(member: Leader | Member | None) → Dict[ str, Any] | None View on GitHub
-
+
- recovery_conf_exists() → bool View on GitHub
-
+
- reload_config(config: Dict[ str, Any], sighup: bool = False) → None View on GitHub
-
+
- remove_recovery_conf() → None View on GitHub
-
+
- replace_pg_hba() → bool | None View on GitHub
-
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() → bool | None View on GitHub
-
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: Dict[ str, Any]_
-
+
- resolve_connection_addresses() → None View on GitHub
-
Calculates and sets local and remote connection urls and options. +
- This method sets
-
+ Note
If there is a valid directory in `+postgresql.parameters.unix_socket_directories+` in the Patroni configuration and `+postgresql.use_unix_socket+` and/or `+postgresql.use_unix_socket_repl+` are set to `+True+`, we respectively use unix sockets for superuser and replication connections to local postgres.
If there is a requirement to use unix sockets, but nothing is set in the `+postgresql.parameters.unix_socket_directories+`, we omit a `+host+` in connection parameters relying on the ability of `+libpq+` to connect via some default unix socket directory.
If unix sockets are not requested we “switch” to TCP, prefering to use `+localhost+` if it is possible to deduce that Postgres is listening on a local interface address.
Otherwise we just used the first address specified in the `+listen_addresses+` GUC. +
- restore_command() → str | None View on GitHub
-
+
- restore_configuration_files() → None View on GitHub
-
restore a previously saved postgresql.conf +
- property _rewind_credentials: Dict[ str, Any]_
-
+
- save_configuration_files(check_custom_bootstrap: bool = False) → bool View on GitHub
-
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 View on GitHub
-
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: str | None) → bool | None View on GitHub
-
Updates synchronous_standby_names and reloads if necessary. :returns: True if value was updated. +
- setup_server_parameters() → None View on GitHub
-
+
- property _superuser: Dict[ str, Any]_
-
+
- property _triggerfile_good_name: str_
-
+
- try_to_create_dir(d: str, msg: str) → None View on GitHub
-
+
- write_pgpass(record: Dict[ str, Any]) → Dict[ str, str] View on GitHub
-
+
- write_postgresql_conf(configuration: CaseInsensitiveDict | None = None) → None View on GitHub
-
+
- write_recovery_conf(recovery_params: CaseInsensitiveDict) → None View on GitHub
- class _patroni.postgresql.config.ConfigWriter(_filename: str) View on GitHub
-
Bases:
object
+- __init\\__(filename: str) → None View on GitHub
-
+
- static _escape(_value: Any) → str View on GitHub
-
+
- write_param(param: str, value: Any) → None View on GitHub
-
+
- writeline(line: str) → None View on GitHub
-
+
- writelines(lines: List[ str | None]) → None View on GitHub
- patroni.postgresql.config.bool_is_true_validator(_value: Any) → bool View on GitHub
- patroni.postgresql.config.bool_validator(_value: Any) → bool View on GitHub
- patroni.postgresql.config.false_validator(_value: Any) → bool View on GitHub
- patroni.postgresql.config.conninfo_parse(dsn: str) → Dict[ str, str] | None View on GitHub
- patroni.postgresql.config.conninfo_uri_parse(dsn: str) → Dict[ str, str] View on GitHub
- patroni.postgresql.config.get_param_diff(old_value: Any, new_value: Any, vartype: str | None = None, unit: str | None = None) → Dict[ str, str] View on GitHub
-
Get a dictionary representing a single PG parameter’s value diff. +
- patroni.postgresql.config.mtime(filename: str) → float | None View on GitHub
- patroni.postgresql.config.parse_dsn(value: str) → Dict[ str, str] | None View on GitHub
-
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
>>> 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'
© Copyright 2015 Compose, Zalando SE. Revision 9d231aee
.
Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
+ Builds