patroni.postgresql.rewind module

class _patroni.postgresql.rewind.REWIND_STATUS(_value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) View on GitHub

Bases: IntEnum +

CHECK_ = 2_

+

CHECKPOINT_ = 1_

+

FAILED_ = 6_

+

INITIAL_ = 0_

+

NEED_ = 3_

+

NOT_NEED_ = 4_

+

SUCCESS_ = 5_
class _patroni.postgresql.rewind.Rewind(_postgresql: Postgresql) View on GitHub

Bases: object +

__checkpoint(_task: CriticalTask_, wakeup: Callable[[…​], Any]) → None

+

__init\\__(postgresql: Postgresql) → None View on GitHub

+

_archive_ready_wals() → None View on GitHub

Try to archive WALs that have .ready files just in case archive_mode was not set to ‘always’ before promote, while after it the WALs were recycled on the promoted replica. With this we prevent the entire loss of such WALs and the consequent old leader’s start failure. +

buid_archiver_command(_command: str, wal_filename: str) → str View on GitHub

Replace placeholders in the given archiver command’s template. Applicable for archive_command and restore_command. Can also be used for archive_cleanup_command and recovery_end_command, however %r value is always set to 000000010000000000000001. +

check_timeline_and_lsn(_leader: Leader | RemoteMember) → None View on GitHub

+

conn_kwargs(_member: Leader | RemoteMember, auth: Dict[ str, Any]) → Dict[ str, Any] View on GitHub

+

fetch_missing_wal(_restore_command: str, wal_filename: str) → bool View on GitHub

+

find_missing_wal(_data: bytes) → str | None View on GitHub

+

get_checkpoint_end(_timeline: int, lsn: int) → int View on GitHub

Get the end of checkpoint record from WAL. + Note

The checkpoint record size in WAL depends on postgres major version and platform (memory alignment). Hence, the only reliable way to figure out where it ends, is to read the record from file with the help of `+pg_waldump+` and parse the output.
We are trying to read two records, and expect that it will fail to read the second record with message:
\\__\\__
fatal: error in WAL record at 0/182E220: invalid record length at 0/182E298: wanted 24, got 0; or
fatal: error in WAL record at 0/182E220: invalid record length at 0/182E298: expected at least 24, got 0
\\__\\__
  The error message contains information about LSN of the next record, which is exactly where checkpoint ends.
  +
  Parameters:::
  Returns:::
    the end of checkpoint record as  https://docs.python.org/3/library/functions.html#int[`+int+`] or `+0+` if failed to parse `+pg_waldump+` output.
+
_get_local_timeline_lsn() → Tuple[ bool | None, int | None, int | None] View on GitHub

+

_get_local_timeline_lsn_from_controldata() → Tuple[ bool | None, int | None, int | None] View on GitHub

+

static \\__log_primary_history(_history: List[ Tuple[ int, int, str]], i: int) → None View on GitHub

+

_maybe_clean_pg_replslot() → None View on GitHub

Clean pg_replslot directory if pg version is less then 11 (pg_rewind deletes $PGDATA/pg_replslot content only since pg11). +

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]) → str | None View on GitHub

+

static _check_leader_is_not_in_recovery(_conn_kwargs: Dict[ str, Any]) → bool | None View on GitHub

+

checkpoint_after_promote() → bool View on GitHub

+

cleanup_archive_status() → None View on GitHub

+

static _configuration_allows_rewind(_data: Dict[ str, str]) → bool View on GitHub

+

property _enabled: bool_

+

ensure_checkpoint_after_promote(wakeup: Callable[[…​], Any]) → None View on GitHub

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() → bool | None View on GitHub

+

execute(leader: Leader | RemoteMember) → bool | None View on GitHub

+

property _executed: bool_

+

property _failed: bool_

+

property _is_needed: bool_

+

pg_rewind(r: Dict[ str, Any]) → bool View on GitHub

+

read_postmaster_opts() → Dict[ str, str] View on GitHub

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

reset_state() → None View on GitHub

+

rewind_or_reinitialize_needed_and_possible(leader: Leader | RemoteMember | None) → bool View on GitHub

+

property _should_remove_data_directory_on_diverged_timelines: bool_

+

single_user_mode(communicate: Dict[ str, Any] | None = None, options: Dict[ str, str] | None = None) → int | None View on GitHub

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

trigger_check_diverged_lsn() → None View on GitHub

© Copyright 2015 Compose, Zalando SE. Revision 9d231aee.

Built with Sphinx using a theme provided by Read the Docs.

Read the Docs v: latest

+ Builds