From 2037c854e8c4a14b8f20de0a0346edf562e40edd Mon Sep 17 00:00:00 2001 From: Neil Shen Date: Wed, 15 Mar 2023 17:19:39 +0800 Subject: [PATCH 1/2] scheduler(ticdc): log splits Signed-off-by: Neil Shen --- .../internal/v3/keyspan/splitter_region_count.go | 13 +++++++++++++ .../internal/v3/keyspan/splitter_write.go | 14 +++++++++++++- 2 files changed, 26 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..dd8ff181d74 100644 --- a/cdc/scheduler/internal/v3/keyspan/splitter_region_count.go +++ b/cdc/scheduler/internal/v3/keyspan/splitter_region_count.go @@ -54,6 +54,12 @@ func (m *regionCountSplitter) split( 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.Int("totalCaptures", totalCaptures), + zap.Int("regionCount", len(regions)), + zap.Int("regionThreshold", config.RegionThreshold)) return []tablepb.Span{span} } @@ -110,6 +116,13 @@ 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.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..e132865d56b 100644 --- a/cdc/scheduler/internal/v3/keyspan/splitter_write.go +++ b/cdc/scheduler/internal/v3/keyspan/splitter_write.go @@ -49,16 +49,28 @@ 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.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.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.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 } From 93f3626d18c6e43a0122f4500caa34d718cf81cf Mon Sep 17 00:00:00 2001 From: Neil Shen Date: Thu, 16 Mar 2023 11:58:39 +0800 Subject: [PATCH 2/2] log span Signed-off-by: Neil Shen --- cdc/scheduler/internal/v3/keyspan/splitter_region_count.go | 6 ++++++ cdc/scheduler/internal/v3/keyspan/splitter_write.go | 3 +++ 2 files changed, 9 insertions(+) diff --git a/cdc/scheduler/internal/v3/keyspan/splitter_region_count.go b/cdc/scheduler/internal/v3/keyspan/splitter_region_count.go index dd8ff181d74..86e4d0a3b50 100644 --- a/cdc/scheduler/internal/v3/keyspan/splitter_region_count.go +++ b/cdc/scheduler/internal/v3/keyspan/splitter_region_count.go @@ -50,6 +50,7 @@ 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} } @@ -57,6 +58,7 @@ func (m *regionCountSplitter) split( 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)) @@ -76,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} } @@ -84,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} } @@ -92,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} @@ -119,6 +124,7 @@ func (m *regionCountSplitter) split( 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)), diff --git a/cdc/scheduler/internal/v3/keyspan/splitter_write.go b/cdc/scheduler/internal/v3/keyspan/splitter_write.go index e132865d56b..4ef4d130040 100644 --- a/cdc/scheduler/internal/v3/keyspan/splitter_write.go +++ b/cdc/scheduler/internal/v3/keyspan/splitter_write.go @@ -52,6 +52,7 @@ func (m *writeSplitter) 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 } @@ -59,6 +60,7 @@ func (m *writeSplitter) split( 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} } @@ -66,6 +68,7 @@ func (m *writeSplitter) split( 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.Int("spans", len(info.Spans)),