nebula icon indicating copy to clipboard operation
nebula copied to clipboard

meta元数据的snapshot同步时会把leader的commitLogId也会同步给follow,follow重启后误以为自己的commitLogId是最新

Open sillylly opened this issue 9 months ago • 0 comments

meta元数据的snapshot同步时会把leader的commitLogId也会同步给follow,导致follow误以为自己的commitLogId已经是最新的了,实际并没有同步完成,造成元数据丢失的问题

1、如果是元数据同步就只直接返回空串作为要同步的数据prefix

if (partId == 0) {
    result.emplace_back("");
}

2、查询元数据以prefix开头的所有数据,这里就包含了SystemCommit信息

auto ret = store_->prefix(spaceId, partId, prefix, &iter, false, snapshot);

3、通过回调函数cb直接把数据全部同步给follow

if (cb(commitLogId,
             commitLogTerm,
             data,
             totalCount,
             totalSize,
             raftex::SnapshotStatus::IN_PROGRESS)) {
    ...

回调函数:

 auto f = send(spaceId,
                          partId,
                          termId,
                          commitLogId,
                          commitLogTerm,
                          localhost,
                          data,
                          totalSize,
                          totalCount,
                          dst,
                          status == SnapshotStatus::DONE);

https://github.com/vesoft-inc/nebula/blob/1f3c6b2c2287cf5c4ba6b8d4c057a2a045326c4b/src/common/utils/NebulaKeyUtils.cpp#L254

sillylly avatar Mar 11 '25 08:03 sillylly