patroni.postgresql.rewind module

class patroni.postgresql.rewind.REWIND_STATUS(value)

Bases: enum.IntEnum

An enumeration.

CHECK = 2
CHECKPOINT = 1
FAILED = 6
INITIAL = 0
NEED = 3
NOT_NEED = 4
SUCCESS = 5
class patroni.postgresql.rewind.Rewind(postgresql: patroni.postgresql.Postgresql)

Bases: object

property can_rewind: bool

check if pg_rewind executable is there and that pg_controldata indicates we have either wal_log_hints or checksums turned on

property can_rewind_or_reinitialize_allowed: bool
static check_leader_has_run_checkpoint(conn_kwargs: Dict[str, Any]) Optional[str]
static check_leader_is_not_in_recovery(conn_kwargs: Dict[str, Any]) Optional[bool]
checkpoint_after_promote() bool
cleanup_archive_status() None
static configuration_allows_rewind(data: Dict[str, str]) bool
property enabled: bool
ensure_checkpoint_after_promote(wakeup: Callable[[...], Any]) None

After promote issue a CHECKPOINT from a new thread and asynchronously check the result. In case if CHECKPOINT failed, just check that timeline in pg_control was updated.

ensure_clean_shutdown() Optional[bool]
execute(leader: Union[patroni.dcs.Leader, patroni.dcs.RemoteMember]) Optional[bool]
property executed: bool
property failed: bool
property is_needed: bool
pg_rewind(r: Dict[str, Any]) bool
read_postmaster_opts() Dict[str, str]

returns the list of option names/values from postgres.opts, Empty dict if read failed or no file

reset_state() None
rewind_or_reinitialize_needed_and_possible(leader: Optional[Union[patroni.dcs.Leader, patroni.dcs.RemoteMember]]) bool
property should_remove_data_directory_on_diverged_timelines: bool
single_user_mode(communicate: Optional[Dict[str, Any]] = None, options: Optional[Dict[str, str]] = None) Optional[int]

run a given command in a single-user mode. If the command is empty - then just start and stop

trigger_check_diverged_lsn() None