box.ctl.on_recovery_state()
-
box.ctl.
on_recovery_state
(trigger-function)¶ Since: 2.11.0
Create a trigger executed on different stages of a node recovery or initial configuration. Note that you need to set the
box.ctl.on_recovery_state
trigger before the initial box.cfg call.Параметры: - trigger-function (
function
) – a trigger function
Return: nil
or a function pointerA registered trigger function is run on each of the supported recovery state and receives the state name as a parameter:
snapshot_recovered
: the node has recovered the snapshot files.wal_recovered
: the node has recovered the WAL files.indexes_built
: the node has built secondary indexes for memtx spaces. This stage might come before any actual data is recovered. This means that the indexes are available right after the first tuple is recovered.synced
: the node has synced with enough remote peers. This means that the node changes the state from orphan torunning
.
All these states are passed during the initial
box.cfg
call when recovering from the snapshot and WAL files. Note that thesynced
state might be reached after the initialbox.cfg
call finishes. For example, if replication_sync_timeout is set to 0, the node finishesbox.cfg
without reachingsynced
and staysorphan
. Once the node is synced with enough remote peers, thesynced
state is reached.Примечание
When bootstrapping a fresh cluster with no data, all the instances in this cluster execute triggers on the same stages for consistency. For example,
snapshot_recovered
andwal_recovered
run when the node finishes a cluster’s bootstrap or finishes joining to an existing cluster.Example:
The example below shows how to log a specified message when each state is reached.
local log = require('log') local log_recovery_state = function(state) log.info(state .. ' state reached') end box.ctl.on_recovery_state(log_recovery_state)
- trigger-function (