pub
struct
CmdBatch {
pub level: ObserveLevel,
pub cdc_id: ObserveId,
pub rts_id: ObserveId,
pub pitr_id: ObserveId,
pub region_id:
u64,
pub cmds:
Vec<Cmd>,
}
impl
Default
for BackupStreamConfig {
fn
default() ->
Self {
// ...
Self {
min_ts_interval: ReadableDuration::secs(
10),
max_flush_interval: ReadableDuration::minutes(
3),
// ...
}
}
}
async
fn
after(&
mut
self, task: &
str, _rts:
u64) ->
Result<()> {
let flush_task = Task::RegionCheckpointsOp(RegionCheckpointOperation::FlushWith(
std::mem::take(&
mut
self.checkpoints),
));
//Update checkpoint
try_send!(
self.sched, flush_task);
let global_checkpoint =
self.get_checkpoint(task).
await?;
info!(
"getting global checkpoint from cache for updating.";
"checkpoint" => ?global_checkpoint);
self.baseline
.after(task, global_checkpoint.ts.into_inner())
//update safepoint
.
await?;
Ok(())
}
订阅更新来自 TiKV 的 FlushTSO 更新。
处理可能的错误并计算 Global Checkpoint。
计算总体更新进度并汇报给 PD。
func
(c *CheckpointAdvancer)
tick
(ctx context.Context)
error {
//...
var errs error
cx, cancel := context.WithTimeout(ctx, c.Config().TickTimeout())
defer cancel()
err := c.optionalTick(cx)
if err !=
nil {
// ...
}
err = c.importantTick(ctx)
if err !=
nil {
// ...
}
return errs
}
isLagged, err := c.isCheckpointLagged(ctx)
if err !=
nil {
return errors.Annotate(err,
"failed to check timestamp")
}
if isLagged {
err := c.env.PauseTask(ctx, c.task.Name)
if err !=
nil {
return errors.Annotate(err,
"failed to pause task")
}
return errors.Annotate(errors.Errorf(
"check point lagged too large"),
"check point lagged too large")
}BackupStreamObserver: https://github.com/tikv/tikv/blob/release-8.0/components/backup-stream/src/observer.rs#L94
[2]Endpoint: https://github.com/tikv/tikv/blob/release-8.0/components/backup-stream/src/endpoint.rs#L1414
[3]backup_stream_scheduler: https://github.com/tikv/tikv/blob/release-8.0/components/server/src/server.rs#L891
[4]on_flush_applied_cmd_batch(): https://github.com/tikv/tikv/blob/release-8.0/components/raftstore/src/coprocessor/mod.rs#L581
[5]Task::BatchEvent: https://github.com/tikv/tikv/blob/release-8.0/components/raftstore/src/coprocessor/mod.rs#L504
[6]backup_batch(): https://github.com/tikv/tikv/blob/release-8.0/components/backup-stream/src/endpoint.rs#L479
[7]router.on_events(): https://github.com/tikv/tikv/blob/release-8.0/components/backup-stream/src/router.rs#L595
[8]endpoint.do_flush(): https://github.com/tikv/tikv/blob/release-8.0/components/backup-stream/src/endpoint.rs#L825
[9]flush_ob.after(): https://github.com/tikv/tikv/blob/release-8.0/components/backup-stream/src/checkpoint_manager.rs#L526
[10]最小值: https://github.com/pingcap/tidb/blob/release-8.0/br/pkg/streamhelper/advancer.go#L295
[11]CheckpointAdvancer: https://github.com/pingcap/tidb/blob/master/br/pkg/streamhelper/advancer.go#L57
[12]FlushSubscriber: https://github.com/pingcap/tidb/blob/release-8.0/br/pkg/streamhelper/flush_subscriber.go#L27
[13]持续监听: https://github.com/pingcap/tidb/blob/release-8.0/br/pkg/streamhelper/flush_subscriber.go#L250
[14]checkpoints: https://github.com/pingcap/tidb/blob/release-8.0/br/pkg/streamhelper/advancer.go#L56
[15]tick(): https://github.com/pingcap/tidb/blob/release-8.0/br/pkg/streamhelper/advancer.go#L645
[16]optionalTick(): https://github.com/pingcap/tidb/blob/master/br/pkg/streamhelper/advancer.go#L622
[17]importantTick(): https://github.com/pingcap/tidb/blob/master/br/pkg/streamhelper/advancer.go#L587
[18]Service Safepoint: https://github.com/pingcap/tidb/blob/master/br/pkg/streamhelper/advancer.go#L605
[19]检查: https://github.com/pingcap/tidb/blob/master/br/pkg/streamhelper/advancer.go#L594
[20]标记为异常状态: https://github.com/pingcap/tidb/blob/master/br/pkg/streamhelper/advancer.go#L598
[21]跳过: https://github.com/pingcap/tidb/blob/master/br/pkg/streamhelper/advancer.go#L646
[22]发送信号: https://github.com/pingcap/tidb/blob/master/br/pkg/streamhelper/advancer.go#L465
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69994146/viewspace-3035305/ ,如需转载,请注明出处,否则将追究法律责任。