26.3. Справка по расширению BiHA #

Подавляющий объём работы BiHA происходит автоматически, лишь некоторые из параметров можно редактировать вручную.

26.3.1. Параметры конфигурации #

Полезные параметры конфигурации:

biha.can_be_leader (boolean) #

Определяет возможность узла стать лидером. Значение по умолчанию — true. Если задано значение false, узел не может предлагать себя в качестве кандидата на выборах лидера.

biha.can_vote (boolean) #

Определяет возможность узла голосовать. Значение по умолчанию — true. Если задать значение false, узел не сможет принимать участие в голосовании, а также не сможет предлагать себя в качестве кандидата в лидеры.

biha.flw_ro (boolean) #

Определяет доступность последователя для операций на чтение. Если задано значение off, чтение с этого последователя запрещено. Значение по умолчанию — on.

biha.heartbeat_max_lost (integer) #

Указывает максимальное число сообщений о контроле состояния, которые можно не получить до того, как узел будет считаться недоступным. Значение по умолчанию — 10.

biha.heartbeat_send_period (integer) #

Указывает частоту отправки сообщений о контроле состояния в миллисекундах. Значение по умолчанию — 1000.

26.3.2. Уровни протоколирования BiHA #

biha.BihaLog_log_level (enum) #

Задаёт уровень протоколирования для предоставления общей информации о работе компонентов BiHA. Значение по умолчанию — LOG.

biha.BcpTransportDebug_log_level (enum) #

Задаёт уровень протоколирования для предоставления отладочной информации о работе канала управления. Значение по умолчанию — DEBUG4.

biha.BcpTransportDetails_log_level (enum) #

Задаёт уровень протоколирования для предоставления подробной информации о работе канала управления. Значение по умолчанию — DEBUG4.

biha.BcpTransportLog_log_level (enum) #

Задаёт уровень протоколирования для предоставления общей информации о работе канала управления. Значение по умолчанию — DEBUG4.

biha.BcpTransportWarn_log_level (enum) #

Задаёт уровень протоколирования для вывода предупреждений о возможных проблемах в канале управления. Значение по умолчанию — DEBUG4.

biha.NodeControllerDebug_log_level (enum) #

Задаёт уровень протоколирования для предоставления отладочной информации о работе контроллера узла. Значение по умолчанию — DEBUG4.

biha.NodeControllerDetails_log_level (enum) #

Задаёт уровень протоколирования для предоставления подробной информации о работе контроллера узла. Значение по умолчанию — DEBUG4.

biha.NodeControllerLog_log_level (enum) #

Задаёт уровень протоколирования для предоставления общей информации о работе контроллера узла. Значение по умолчанию — DEBUG4.

biha.NodeControllerWarn_log_level (enum) #

Задаёт уровень протоколирования для вывода предупреждений о возможных проблемах в контроллере узла. Значение по умолчанию — DEBUG4.

26.3.3. Функции #

Все перечисленные ниже функции следует вызывать из базы данных biha_db:

biha.error_details () returns setof record #

Возвращает описание причины, по которой узел перешёл в состояние NODE_ERROR. Возвращаемая запись содержит тип ошибки, подробную информацию о ней, место возникновения с указанием begin_lsn, end_lsn и идентификаторов текущей и следующей линии времени, а также replay_lsn.

biha.nodes () returns setof record #

Определяет представление biha.nodes_v, подробно описанное в biha.nodes_v.

biha.status () returns setof record #

Определяет представление biha.status_v, подробно описанное в biha.status_v. Если узел не отвечает при попытке показать представление, попробуйте выполнить тот же запрос на любом другом узле, чтобы узнать фактическое состояние узлов кластера.

26.3.4. Представления #

Чтобы обращаться к перечисленным ниже представлениям, необходимо подключиться к базе данных biha_db.

26.3.4.1. biha.nodes_v #

В этом представлении показывается состояние подключения узлов в кластере. Для узла, на котором выполняется запрос для представления, следующие столбцы содержат NULL: state, since_conn_start, conn_count.

Таблица 26.1. Представление biha.nodes_v

Имя столбцаОписание
idИдентификатор узла.
hostАдрес узла.
portПорт узла.
stateСостояние подключения узла. В этом столбце может отображаться одно из следующих значений: ACTIVE, CONNECTING, IDLE или INIT.
since_conn_startВремя, прошедшее с момента подключения узла к сети.
conn_countСколько раз узел подключался к сети с момента запуска кластера.

26.3.4.2. biha.status_v #

В этом представлении показывается состояние узлов в кластере.

Таблица 26.2. Представление biha.status_v

Имя столбцаОписание
idИдентификатор узла (integer).
leader_idИдентификатор узла-лидера (integer).
termПоколение узла (integer). Используется при голосовании на выборах нового узла-лидера.
onlineПоказывает, подключён ли узел к сети (boolean: t или f).
state

Состояние узла (text). В этом столбце может отображаться одно из следующих значений:

  • PRESTARTUP: начальное состояние узла при запуске BiHA-кластера. Узел отправляет сообщения о контроле состояния и запускает pg_rewind, если это было запланировано. В других случаях узел переходит в состояние STARTUP.

  • STARTUP: узел ожидает, пока процесс запуска Postgres Pro Shardman достигнет точки согласованности.

  • CSTATE_FORMING: узел получает и отправляет сообщения о контроле состояния, чтобы определить, в какое состояние он должен перейти.

  • LEADER_RO: узел является лидером, доступным только для операций чтения.

  • LEADER_RW: узел является лидером, доступным для операций на чтение и запись.

  • FOLLOWER: узел является последователем, т.е. репликой лидера. Если biha.can_be_leader и biha.can_vote имеют значение true, последователь может быть избран новым лидером.

  • FOLLOWER_OFFERED — узел был вручную назначен новым лидером.

  • CANDIDATE: узел предложил себя в качестве кандидата на выборах нового лидера.

  • REFEREE — узел является рефери кластера. Это единое состояние для режимов referee и referee_with_wal.

  • NODE_ERROR: узел в нерабочем состоянии из-за ошибки. Узлы в этом состоянии не могут голосовать на выборах. Чтение с таких узлов запрещено. Чтобы получить больше информации об ошибке, используйте функцию biha.error_details. О восстановлении дефектных узлов читайте в разделе Подраздел 26.2.3.

  • UNKNOWN: узел недоступен для текущего узла.

last_known_stateПоследнее известное состояние узла (text).
since_last_hbВремя, прошедшее с момента получения последнего сообщения о контроле состояния (interval).

26.3. Reference for the BiHA Extension #

The majority of BiHA specifics is done automatically, with few parameters available for manual editing.

26.3.1. Configuration Parameters #

Configuration parameters that can be useful:

biha.can_be_leader (boolean) #

Determines the ability of a node to become the leader. The default value is true. If set to false, the node cannot stand as a candidate in elections of the new leader.

biha.can_vote (boolean) #

Determines whether a node is allowed to vote. The default value is true. If set to false, the node cannot vote, as well as cannot stand as a candidate in elections of the new leader.

biha.flw_ro (boolean) #

Determines whether a follower is available for read operations. If set to off, reading from this follower is prohibited. The default value is on.

biha.heartbeat_max_lost (integer) #

Specifies the maximum number of heartbeats that can be missed before the node is considered offline. The default value is 10.

biha.heartbeat_send_period (integer) #

Specifies the heartbeat sending frequency, in milliseconds. The default value is 1000.

26.3.2. BiHA Logging Levels #

biha.BihaLog_log_level (enum) #

Specifies the logging level to provide general information about the operation of BiHA components. The default value is LOG.

biha.BcpTransportDebug_log_level (enum) #

Specifies the logging level to provide debugging information about the control channel operation. The default value is DEBUG4.

biha.BcpTransportDetails_log_level (enum) #

Specifies the logging level to provide detailed information about the control channel operation. The default value is DEBUG4.

biha.BcpTransportLog_log_level (enum) #

Specifies the logging level to provide general information about the control channel operation. The default value is DEBUG4.

biha.BcpTransportWarn_log_level (enum) #

Specifies the logging level to provide warnings of likely problems in the control channel. The default value is DEBUG4.

biha.NodeControllerDebug_log_level (enum) #

Specifies the logging level to provide debugging information about the node controller operation. The default value is DEBUG4.

biha.NodeControllerDetails_log_level (enum) #

Specifies the logging level to provide detailed information about the node controller operation. The default value is DEBUG4.

biha.NodeControllerLog_log_level (enum) #

Specifies the logging level to provide general information about the node controller operation. The default value is DEBUG4.

biha.NodeControllerWarn_log_level (enum) #

Specifies the logging level to provide warnings of likely problems in the node controller. The default value is DEBUG4.

26.3.3. Functions #

All functions listed below should be called from the biha_db database:

biha.error_details () returns setof record #

Returns the description of why the node transferred to the NODE_ERROR state. The returned record contains the type of the error, its details, the place it occurred specifying begin_lsn, end_lsn, and identifier of the current and the next timeline, as well as replay_lsn.

biha.nodes () returns setof record #

Defines the biha.nodes_v view, which is described in detail in the biha.nodes_v section.

biha.status () returns setof record #

Defines the biha.status_v view, which is described in detail in the biha.status_v section. If the node does not respond when trying to display the view, try the same request on any other node to learn the actual state of cluster nodes.

26.3.4. Views #

To query the views listed below, you must first connect to the biha_db database.

26.3.4.1. biha.nodes_v #

This view displays the connection status of nodes in the cluster. For the node that the view is queried on, the following columns contain NULL: state, since_conn_start, conn_count.

Table 26.1. The biha.nodes_v view

Column NameDescription
id The node ID.
host The host of the node.
port The port of the node.
state The connection state of the node. This column may contain one of the following values: ACTIVE, CONNECTING, IDLE, or INIT.
since_conn_start The time since the node connection.
conn_count The number of times the node was connected since the start of the cluster.

26.3.4.2. biha.status_v #

This view displays the state of nodes in the cluster.

Table 26.2. The biha.status_v View

Column NameDescription
id The node ID (integer).
leader_id The leader node ID (integer).
term The term of the node (integer). This is used for the purposes of the leader election.
online Shows whether the node is online (boolean: t or f).
state

The state of the node (text). This column may contain one of the following values:

  • PRESTARTUP: The initial state of the node at the BiHA cluster launch. The node sends heartbeats and executes pg_rewind if scheduled. Otherwise, the node proceeds to STARTUP.

  • STARTUP: The node waits for the Postgres Pro Shardman startup process to reach the consistency point.

  • CSTATE_FORMING: The node receives and sends heartbeats to determine what state it must transfer to.

  • LEADER_RO: The node is the leader available for read-only operations.

  • LEADER_RW: The node is the leader available for read and write operations.

  • FOLLOWER: The node is a replica of the leader. If biha.can_be_leader and biha.can_vote are set to true, the follower can be elected as the new leader.

  • FOLLOWER_OFFERED — the node was manually nominated as the new leader.

  • CANDIDATE: The node stands as a candidate in elections of the new leader.

  • REFEREE — the node is the cluster referee. The state is the same both for the referee and referee_with_wal modes.

  • NODE_ERROR: The node is non-operational due to an error. Nodes in this state are unable to vote during elections. Reading from such nodes is prohibited. To get more information about the error, use the biha.error_details function. To restore the faulty node, see Section 26.2.3.

  • UNKNOWN: The node is offline for the current node.

last_known_state The last known state of the node (text).
since_last_hb The time since the last received heartbeat message (interval).

FAQ