Image + Checkpoint
Checkpoint 相关代码在fe/fe-core/src/main/java/org/apache/doris/master/Checkpoint.java
中,主要部分为 doCheckpoint()
函数
该函数主要逻辑为:
- 检查 imageVersion 和 checkPointVersion 的大小关系, 如果 image版本 比 checkpoint版本新那么直接返回(说明checkpoint过时了不需要做同步)
- 检查内存是否足够去做 checkpoint
- 写 image 文件,做持久化,将 image.ckpt 移动到 image.dataVersion 文件
- 加载 image 文件,检查 image 是否有效,至此 image 文件保存完毕
- 将 image 文件发送给所有非 master fe 节点
- 当 5 完成之后删除它们的旧版本日志
删除 master 的旧版本日志
image文件格式:|- Image --------------------------------------| | - Magic String (4 bytes) | | - Header Length (4 bytes) | | |- Header -----------------------------| | | | |- Json Header ---------------| | | | | | - version | | | | | | - other key/value(undecided)| | | | | |-----------------------------| | | | |--------------------------------------| | | | | |- Image Body -------------------------| | | | Object a | | | | Object b | | | | ... | | | |--------------------------------------| | | | | |- Footer -----------------------------| | | | - Checksum (8 bytes) | | | | |- object index --------------| | | | | | - index a | | | | | | - index b | | | | | | ... | | | | | |-----------------------------| | | | | - other value(undecided) | | | |--------------------------------------| | | - Footer Length (8 bytes) | | - Magic String (4 bytes) | |----------------------------------------------|
相关代码在:
fe/fe-core/src/main/java/org/apache/doris/persist/meta/MetaReader.java
评论 (0)