patroni.postgresql.mpp package
Module contents
Abstract classes for MPP handler.
MPP stands for Massively Parallel Processing, and Citus belongs to this architecture. Currently, Citus is the only supported MPP cluster. However, we may consider adapting other databases such as TimescaleDB, GPDB, etc. into Patroni.
- class _patroni.postgresql.mpp.AbstractMPP(_config: Dict[ str, str | int]) View on GitHub
-
Bases:
ABC
+ An abstract class which should be passed toAbstractDCS
. + NoteWe create link:#patroni.postgresql.mpp.AbstractMPP[`+AbstractMPP+`] and link:#patroni.postgresql.mpp.AbstractMPPHandler[`+AbstractMPPHandler+`] to solve the chicken-egg initialization problem. When initializing DCS, we dynamically create an object implementing link:#patroni.postgresql.mpp.AbstractMPP[`+AbstractMPP+`], later this object is used to instantiate an object implementing link:#patroni.postgresql.mpp.AbstractMPPHandler[`+AbstractMPPHandler+`]. + \\__init\\__(_config: https://docs.python.org/3/library/typing.html#typing.Dict[Dict][ https://docs.python.org/3/library/stdtypes.html#str[str], https://docs.python.org/3/library/stdtypes.html#str[str] | https://docs.python.org/3/library/functions.html#int[int]]_) → https://docs.python.org/3/library/constants.html#None[None] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/postgresql/mpp/\\__init\\__.py#L30-L35[View on GitHub]link:#patroni.postgresql.mpp.AbstractMPP.\\__init\\__[];; Init method for link:#patroni.postgresql.mpp.AbstractMPP[`+AbstractMPP+`]. + Parameters::: *config* – configuration of MPP section. + _abc_impl_ = <_abc._abc_data object>_link:#patroni.postgresql.mpp.AbstractMPP._abc_impl[];; + _get_handler_cls() → https://docs.python.org/3/library/typing.html#typing.Iterator[Iterator][ https://docs.python.org/3/library/typing.html#typing.Type[Type][link:#patroni.postgresql.mpp.AbstractMPPHandler[AbstractMPPHandler]]] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/postgresql/mpp/\\__init\\__.py#L103-L110[View on GitHub]link:#patroni.postgresql.mpp.AbstractMPP._get_handler_cls[];; Find Handler classes inherited from a class type of this object. + Yields::: handler classes for this object. + _abstract property _coordinator_group_id_: https://docs.python.org/3/library/typing.html#typing.Any[Any]_link:#patroni.postgresql.mpp.AbstractMPP.coordinator_group_id[];; The group id of the coordinator PostgreSQL cluster. + get_handler_impl(_postgresql: link:patroni.postgresql.html#patroni.postgresql.Postgresql[Postgresql]_) → link:#patroni.postgresql.mpp.AbstractMPPHandler[AbstractMPPHandler] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/postgresql/mpp/\\__init\\__.py#L112-L124[View on GitHub]link:#patroni.postgresql.mpp.AbstractMPP.get_handler_impl[];; Find and instantiate Handler implementation of this object. + Parameters::: *postgresql* – a reference to `+Postgresql+` object. Raises::: `+PatroniException+`: if the Handler class haven’t been found. Returns::: an instantiated class that implements Handler for this object. + _abstract property _group_: https://docs.python.org/3/library/typing.html#typing.Any[Any]_link:#patroni.postgresql.mpp.AbstractMPP.group[];; The group for a given MPP implementation. + group_re_: https://docs.python.org/3/library/typing.html#typing.Any[Any]_link:#patroni.postgresql.mpp.AbstractMPP.group_re[];; + is_coordinator() → https://docs.python.org/3/library/functions.html#bool[bool] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/postgresql/mpp/\\__init\\__.py#L87-L93[View on GitHub]link:#patroni.postgresql.mpp.AbstractMPP.is_coordinator[];; Check whether this node is running in the coordinator PostgreSQL cluster. + Returns::: `+True+` if MPP is enabled and the group id of this node matches with the link:#patroni.postgresql.mpp.AbstractMPP.coordinator_group_id[`+coordinator_group_id+`], otherwise `+False+`. + is_enabled() → https://docs.python.org/3/library/functions.html#bool[bool] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/postgresql/mpp/\\__init\\__.py#L37-L46[View on GitHub]link:#patroni.postgresql.mpp.AbstractMPP.is_enabled[];; Check if MPP is enabled for a given MPP. + Note
We just check that the `+_config+` object isn’t empty and expect it to be empty only in case of link:#patroni.postgresql.mpp.Null[`+Null+`]. + Returns::: `+True+` if MPP is enabled, otherwise `+False+`. + is_worker() → https://docs.python.org/3/library/functions.html#bool[bool] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/postgresql/mpp/\\__init\\__.py#L95-L101[View on GitHub]link:#patroni.postgresql.mpp.AbstractMPP.is_worker[];; Check whether this node is running as a MPP worker PostgreSQL cluster. + Returns::: `+True+` if MPP is enabled and this node is known to be not running as the coordinator PostgreSQL cluster, otherwise `+False+`. + _property _k8s_group_labellink:#patroni.postgresql.mpp.AbstractMPP.k8s_group_label[];; Group label used for kubernetes DCS of the MPP cluster. + Returns::: A string representation of the k8s group label of a given MPP implementation. + _property _type_: https://docs.python.org/3/library/stdtypes.html#str[str]_link:#patroni.postgresql.mpp.AbstractMPP.type[];; The type of the MPP cluster. + Returns::: A string representation of the type of a given MPP implementation. + _abstract static _validate_config(_config: https://docs.python.org/3/library/typing.html#typing.Any[Any]_) → https://docs.python.org/3/library/functions.html#bool[bool] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/postgresql/mpp/\\__init\\__.py#L48-L56[View on GitHub]link:#patroni.postgresql.mpp.AbstractMPP.validate_config[];; Check whether provided config is good for a given MPP. + Parameters::: *config* – configuration of MPP section. Returns::: `+True+` is config passes validation, otherwise `+False+`.
- class _patroni.postgresql.mpp.AbstractMPPHandler(_postgresql: Postgresql, config: Dict[ str, str | int]) View on GitHub
-
Bases:
AbstractMPP
+ An abstract class which defines interfaces that should be implemented by real handlers. +- __init\\__(postgresql: Postgresql, config: Dict[ str, str | int]) → None View on GitHub
-
Init method for
AbstractMPPHandler
. +- Parameters
-
+
- abc_impl = <_abc._abc_data object>_
-
+
- abstract _adjust_postgres_gucs(_parameters: Dict[ str, Any]) → None View on GitHub
-
Adjust GUCs in the current PostgreSQL configuration. +
- Parameters
-
parameters – dictionary of GUCs, with key as GUC name and the corresponding value as current GUC value. +
- abstract _bootstrap() → None View on GitHub
-
Bootstrap handler.
Is called when the new cluster is initialized (throughinitdb
or a custom bootstrap method). + - abstract _handle_event(_cluster: Cluster, event: Dict[ str, Any]) → None View on GitHub
-
Handle an event sent from a worker node. +
- Parameters
-
+
- abstract _ignore_replication_slot(_slot: Dict[ str, str]) → bool View on GitHub
-
Check whether provided replication slot existing in the database should not be removed. + Note
MPP database may create replication slots for its own use, for example to migrate data between workers using logical replication, and we don’t want to suddenly drop them. + Parameters::: *slot* – dictionary containing the replication slot settings, like `+name+`, `+database+`, `+type+`, and `+plugin+`. Returns::: `+True+` if the replication slots should not be removed, otherwise `+False+`. +
- abstract _on_demote() → None View on GitHub
-
On demote handler.
Is called when the primary was demoted. + - abstract _schedule_cache_rebuild() → None View on GitHub
-
Cache rebuild handler.
Is called to notify handler that it has to refresh its metadata cache from the database. + - abstract _sync_meta_data(_cluster: Cluster) → None View on GitHub
-
Sync meta data on the coordinator. +
- Parameters
-
cluster – the currently known cluster state from DCS.
- class _patroni.postgresql.mpp.Null View on GitHub
-
Bases:
AbstractMPP
+ Dummy implementation ofAbstractMPP
. +- __init\\__() → None View on GitHub
-
Init method for
Null
. + - abc_impl = <_abc._abc_data object>_
-
+
- property _coordinator_group_id: None_
-
The group id of the coordinator PostgreSQL cluster. +
- Returns
-
always
None
. +
- property _group: None_
-
The group for
Null
. +- Returns
-
always
None
. +
- static _validate_config(_config: Any) → bool View on GitHub
-
Check whether provided config is good for
Null
. +- Returns
-
always
True
.
- class _patroni.postgresql.mpp.NullHandler(_postgresql: Postgresql, config: Dict[ str, str | int]) View on GitHub
-
Bases:
Null
,AbstractMPPHandler
+ Dummy implementation ofAbstractMPPHandler
. +- __init\\__(postgresql: Postgresql, config: Dict[ str, str | int]) → None View on GitHub
-
Init method for
NullHandler
. +- Parameters
-
+
- abc_impl = <_abc._abc_data object>_
-
+
- adjust_postgres_gucs(parameters: Dict[ str, Any]) → None View on GitHub
-
Adjust GUCs in the current PostgreSQL configuration. +
- Parameters
-
parameters – dictionary of GUCs, with key as GUC name and corresponding value as current GUC value. +
- bootstrap() → None View on GitHub
-
Bootstrap handler.
Is called when the new cluster is initialized (throughinitdb
or a custom bootstrap method). + - handle_event(cluster: Cluster, event: Dict[ str, Any]) → None View on GitHub
-
Handle an event sent from a worker node. +
- Parameters
-
+
- ignore_replication_slot(slot: Dict[ str, str]) → bool View on GitHub
-
Check whether provided replication slot existing in the database should not be removed. + Note
MPP database may create replication slots for its own use, for example to migrate data between workers using logical replication, and we don’t want to suddenly drop them. + Parameters::: *slot* – dictionary containing the replication slot settings, like `+name+`, `+database+`, `+type+`, and `+plugin+`. Returns::: always `+False+`. +
- on_demote() → None View on GitHub
-
On demote handler.
Is called when the primary was demoted. + - schedule_cache_rebuild() → None View on GitHub
-
Cache rebuild handler.
Is called to notify handler that it has to refresh its metadata cache from the database. + - sync_meta_data(cluster: Cluster) → None View on GitHub
-
Sync meta data on the coordinator. +
- Parameters
-
cluster – the currently known cluster state from DCS.
- patroni.postgresql.mpp.get_mpp(config: Config | Dict[ str, Any]) → AbstractMPP View on GitHub
-
Attempt to load and instantiate a MPP module from known available implementations. +
- Parameters:
-
config – object or dictionary with Patroni configuration.
- Returns:
-
The successfully loaded MPP or fallback to
Null
.
- patroni.postgresql.mpp.iter_mpp_classes(config: Config | Dict[ str, Any] | None = None) → Iterator[ Tuple[ str, Type[AbstractMPP]]] View on GitHub
-
Attempt to import MPP modules that are present in the given configuration. +
- Parameters:
-
config – configuration information with possible MPP names as keys. If given, only attempt to import MPP modules defined in the configuration. Else, if
None
, attempt to import any supported MPP module. - Yields:
-
tuples, each containing the module
name
and the imported MPP class object.
© Copyright 2015 Compose, Zalando SE. Revision 9d231aee
.
Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
+ Builds