Closed dingxiaoshuai123 closed 7 months ago
需要把do_checkpoint包装在on_snapshot_save里,然后可以通过主动调用braft的do_snapshot去异步驱动状态机里的on_snapshot_save。另一个要实现的就是on_snapshot_load,这个可以用来Install snapshot,但是这里需要注意一个事情就是,在正常启动时也会调用这个函数,所以在程序刚启动时,可以先设一个flag表示自己是刚启动,然后把flag置反,直接跳出函数就地启动即可,不去install snapshot。
Bot detected the issue body's language is not English, translate it automatically.
Do_checkpoint needs to be packaged in on_snapshot_save, and then on_snapshot_save in the state machine can be asynchronously driven by actively calling braft's do_snapshot. Another thing to implement is on_snapshot_load, which can be used to install snapshot, but one thing to note here is that this function will also be called during normal startup, so when the program just starts, you can first set a flag to indicate that it has just started. , then set the flag to the reverse position, and just jump out of the function and start it on the spot without installing the snapshot.
暂时使用 中文 注释,方便 review 。 借用了 get 和 set 命令发起 同步和异步 checkpoint 。调用 PSTORE 的接口,可传入 DB index 和 checkpointPath 指定 DB 在指定的路径下生成 checkpoint 。 比如在 ./dump 目录下生成所有 DB 的 checkpoint 。 以 2 个 DB ,每一个 DB 下有 2 个 Rocksdb 为例, 生成的 dump 目录结构如下 :
可以在 on_snapshot_save 函数下,调用 PSTORE 的接口生成 Checkpoint 。 TODO : 1、提供 Load Checkpoint 的接口, 从指定的路径打开一个新的 DB,完成快照的安装。
review 时任何问题请 comment 或者 微信。