【发布时间】:2019-08-08 00:31:01
【问题描述】:
我需要将 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
- 如果我在架构初始化时设置触发器,它会以只读方式失败
错误。在尝试 upsert read_only
stat空间时。 - 如果我将其设置为
box.info.ro == False,它会跳过 replication_sync。
我发现最适合设置触发器的时间是一瞬间,然后box.info.status 从loading 更改为running。我解决了我的问题,例如this。但我想知道是否有更好的方法?
我想过在box.info.status 字段上设置回调函数已更改。我怎样才能做到这一点?
【问题讨论】: