Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduler(ticdc): log splits #8543

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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