Skip to content

Commit

Permalink
scheduler(ticdc): log splits (pingcap#8543)
Browse files Browse the repository at this point in the history
  • Loading branch information
overvenus authored Mar 16, 2023
1 parent 7848c0c commit f2c2026
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
19 changes: 19 additions & 0 deletions cdc/scheduler/internal/v3/keyspan/splitter_region_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,18 @@ func (m *regionCountSplitter) split(
log.Warn("schedulerv3: list regions failed, skip split span",
zap.String("namespace", m.changefeedID.Namespace),
zap.String("changefeed", m.changefeedID.ID),
zap.String("span", span.String()),
zap.Error(err))
return []tablepb.Span{span}
}
if len(regions) <= config.RegionThreshold || totalCaptures == 0 {
log.Info("schedulerv3: skip split span by region count",
zap.String("namespace", m.changefeedID.Namespace),
zap.String("changefeed", m.changefeedID.ID),
zap.String("span", span.String()),
zap.Int("totalCaptures", totalCaptures),
zap.Int("regionCount", len(regions)),
zap.Int("regionThreshold", config.RegionThreshold))
return []tablepb.Span{span}
}

Expand All @@ -70,6 +78,7 @@ func (m *regionCountSplitter) split(
log.Warn("schedulerv3: get regions failed, skip split span",
zap.String("namespace", m.changefeedID.Namespace),
zap.String("changefeed", m.changefeedID.ID),
zap.String("span", span.String()),
zap.Error(err))
return []tablepb.Span{span}
}
Expand All @@ -78,6 +87,7 @@ func (m *regionCountSplitter) split(
log.Warn("schedulerv3: get regions failed, skip split span",
zap.String("namespace", m.changefeedID.Namespace),
zap.String("changefeed", m.changefeedID.ID),
zap.String("span", span.String()),
zap.Error(err))
return []tablepb.Span{span}
}
Expand All @@ -86,6 +96,7 @@ func (m *regionCountSplitter) split(
log.Warn("schedulerv3: list region out of order detected",
zap.String("namespace", m.changefeedID.Namespace),
zap.String("changefeed", m.changefeedID.ID),
zap.String("span", span.String()),
zap.Stringer("lastSpan", &spans[len(spans)-1]),
zap.Stringer("region", startRegion))
return []tablepb.Span{span}
Expand All @@ -110,6 +121,14 @@ func (m *regionCountSplitter) split(
// Make sure spans does not exceed [startKey, endKey).
spans[0].StartKey = span.StartKey
spans[len(spans)-1].EndKey = span.EndKey
log.Info("schedulerv3: split span by region count",
zap.String("namespace", m.changefeedID.Namespace),
zap.String("changefeed", m.changefeedID.ID),
zap.String("span", span.String()),
zap.Int("spans", len(spans)),
zap.Int("totalCaptures", totalCaptures),
zap.Int("regionCount", len(regions)),
zap.Int("regionThreshold", config.RegionThreshold))
return spans
}

Expand Down
17 changes: 16 additions & 1 deletion cdc/scheduler/internal/v3/keyspan/splitter_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,31 @@ func (m *writeSplitter) split(
regions, err := m.pdAPIClient.ScanRegions(ctx, span)
if err != nil {
// Skip split.
log.Warn("schedulerv3: scan regions failed, skip split span",
zap.String("namespace", m.changefeedID.Namespace),
zap.String("changefeed", m.changefeedID.ID),
zap.String("span", span.String()),
zap.Error(err))
return nil
}
if totalCaptures <= 1 {
log.Warn("schedulerv3: only one capture, skip split span",
zap.String("namespace", m.changefeedID.Namespace),
zap.String("changefeed", m.changefeedID.ID),
zap.String("span", span.String()),
zap.Error(err))
return []tablepb.Span{span}
}
info := splitRegionsByWrittenKeys(span.TableID, regions, config.WriteKeyThreshold, totalCaptures)
log.Info("schedulerv3: split span by written keys",
zap.String("namespace", m.changefeedID.Namespace),
zap.String("changefeed", m.changefeedID.ID),
zap.String("span", span.String()),
zap.Ints("counts", info.Counts),
zap.Ints("weights", info.Weights),
zap.String("span", span.String()))
zap.Int("spans", len(info.Spans)),
zap.Int("totalCaptures", totalCaptures),
zap.Int("writeKeyThreshold", config.WriteKeyThreshold))
return info.Spans
}

Expand Down

0 comments on commit f2c2026

Please sign in to comment.