我需要将 box.info.status 从“正在加载”更改为“准备就绪”。所以我可以在 WAL 读取之后,但在复制同步之前启用我的触发器。
我的触发功能box.space.myspace
:
local function before_replace(old, new)
-- collision resolving here
if box.session.type() ~= 'applier' then
box.space.stat:upsert(
{ "key", 0 },
{
{"+", stat.COUNT, 1}
})
end
return
end
- 如果我在架构初始化时设置触发器,它会因 read_only 错误而失败。在尝试 upsert read_only
stat
空间时。 - 如果我将其设置为它
box.info.ro == False
会跳过replication_sync。
我发现最适合设置触发器的时间是片刻,然后box.info.status
从 更改loading
为running
。我这样解决我的问题。但我想知道是否有更好的方法?
我想过在box.info.status
字段更改时设置回调函数。我怎样才能做到这一点?