From f2c2026715745a19fffe34e46549d68fc3dfed2d Mon Sep 17 00:00:00 2001 From: Neil Shen Date: Thu, 16 Mar 2023 15:22:39 +0800 Subject: [PATCH] scheduler(ticdc): log splits (#8543) ref pingcap/tiflow#7720 --- .../v3/keyspan/splitter_region_count.go | 19 +++++++++++++++++++ .../internal/v3/keyspan/splitter_write.go | 17 ++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/cdc/scheduler/internal/v3/keyspan/splitter_region_count.go b/cdc/scheduler/internal/v3/keyspan/splitter_region_count.go index 49678971c1d..86e4d0a3b50 100644 --- a/cdc/scheduler/internal/v3/keyspan/splitter_region_count.go +++ b/cdc/scheduler/internal/v3/keyspan/splitter_region_count.go @@ -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} } @@ -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} } @@ -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} } @@ -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} @@ -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 } diff --git a/cdc/scheduler/internal/v3/keyspan/splitter_write.go b/cdc/scheduler/internal/v3/keyspan/splitter_write.go index 8f7bc3a9a2d..4ef4d130040 100644 --- a/cdc/scheduler/internal/v3/keyspan/splitter_write.go +++ b/cdc/scheduler/internal/v3/keyspan/splitter_write.go @@ -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 }