patroni.postgresql.rewind module

class patroni.postgresql.rewind.REWIND_STATUS

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

can_rewind

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

can_rewind_or_reinitialize_allowed
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
enabled
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]
executed
failed
is_needed
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: Union[patroni.dcs.Leader, patroni.dcs.RemoteMember, None]) → bool
should_remove_data_directory_on_diverged_timelines
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