Skip to content

Commit c925e86

Browse files
committed
changefeedccl: allow for more tables in bank workload
When running the bank workload with thousands of tables, the workload would fail to initialize all the tables because it was using too high concurrency. This PR sets a sensible default, allowing us to add tests of multi-table changefeed functionality with more tables (up to 50_000). Epic: CRDB-1421 Release note: None
1 parent 517d0c7 commit c925e86

File tree

2 files changed

+55
-7
lines changed

2 files changed

+55
-7
lines changed

pkg/cmd/roachtest/tests/cdc.go

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,6 +1787,7 @@ func runMessageTooLarge(ctx context.Context, t test.Test, c cluster.Cluster) {
17871787

17881788
type multiTablePTSBenchmarkParams struct {
17891789
numTables int
1790+
numRanges int
17901791
numRows int
17911792
duration string
17921793
}
@@ -1812,8 +1813,13 @@ func runCDCMultiTablePTSBenchmark(
18121813
t.Fatalf("failed to set cluster settings: %v", err)
18131814
}
18141815

1815-
initCmd := fmt.Sprintf("./cockroach workload init bank --rows=%d --num-tables=%d {pgurl%s}",
1816-
params.numRows, params.numTables, ct.crdbNodes.RandNode())
1816+
numRanges := 10
1817+
if params.numRanges > 0 {
1818+
numRanges = params.numRanges
1819+
}
1820+
1821+
initCmd := fmt.Sprintf("./cockroach workload init bank --rows=%d --ranges=%d --num-tables=%d {pgurl%s}",
1822+
params.numRows, numRanges, params.numTables, ct.crdbNodes.RandNode())
18171823
if err := c.RunE(ctx, option.WithNodes(ct.workloadNode), initCmd); err != nil {
18181824
t.Fatalf("failed to initialize bank tables: %v", err)
18191825
}
@@ -1855,11 +1861,11 @@ func runCDCMultiTablePTSBenchmark(
18551861
t.Status("workload finished, verifying metrics")
18561862

18571863
// These metrics are in nanoseconds, so we are asserting that both
1858-
// of these latency metrics are less than 10 milliseconds.
1859-
ct.verifyMetrics(ctx, verifyMetricsUnderThreshold([]string{
1864+
// of these latency metrics are less than 25 milliseconds.
1865+
ct.verifyMetrics(ctx, ct.verifyMetricsUnderThreshold([]string{
18601866
"changefeed_stage_pts_manage_latency",
18611867
"changefeed_stage_pts_create_latency",
1862-
}, float64(10*time.Millisecond)))
1868+
}, float64(25*time.Millisecond)))
18631869

18641870
t.Status("multi-table PTS benchmark finished")
18651871
}
@@ -2897,7 +2903,7 @@ func registerCDC(r registry.Registry) {
28972903
Run: runMessageTooLarge,
28982904
})
28992905
r.Add(registry.TestSpec{
2900-
Name: "cdc/multi-table-pts-benchmark",
2906+
Name: "cdc/multi-table-pts-benchmark/num-tables=500",
29012907
Owner: registry.OwnerCDC,
29022908
Benchmark: true,
29032909
Cluster: r.MakeClusterSpec(4, spec.CPU(16), spec.WorkloadNode()),
@@ -2913,6 +2919,43 @@ func registerCDC(r registry.Registry) {
29132919
runCDCMultiTablePTSBenchmark(ctx, t, c, params)
29142920
},
29152921
})
2922+
r.Add(registry.TestSpec{
2923+
Name: "cdc/multi-table-pts-benchmark/num-tables=5000",
2924+
Owner: registry.OwnerCDC,
2925+
Benchmark: true,
2926+
Cluster: r.MakeClusterSpec(4, spec.CPU(16), spec.WorkloadNode()),
2927+
CompatibleClouds: registry.AllClouds,
2928+
Suites: registry.Suites(registry.Nightly),
2929+
Timeout: 1 * time.Hour,
2930+
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
2931+
params := multiTablePTSBenchmarkParams{
2932+
numTables: 5000,
2933+
numRows: 100,
2934+
duration: "20m",
2935+
}
2936+
runCDCMultiTablePTSBenchmark(ctx, t, c, params)
2937+
},
2938+
})
2939+
r.Add(registry.TestSpec{
2940+
Name: "cdc/multi-table-pts-benchmark/num-tables=50000",
2941+
Owner: registry.OwnerCDC,
2942+
Benchmark: true,
2943+
Cluster: r.MakeClusterSpec(4, spec.CPU(16), spec.WorkloadNode()),
2944+
CompatibleClouds: registry.AllClouds,
2945+
Suites: registry.Suites(registry.Nightly),
2946+
Timeout: 1 * time.Hour,
2947+
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
2948+
params := multiTablePTSBenchmarkParams{
2949+
numTables: 50_000,
2950+
// Splitting tables into ranges slows down test setup at this scale.
2951+
// Therefore, we don't split the tables into multiple ranges.
2952+
numRanges: 1,
2953+
numRows: 10,
2954+
duration: "20m",
2955+
}
2956+
runCDCMultiTablePTSBenchmark(ctx, t, c, params)
2957+
},
2958+
})
29162959
}
29172960

29182961
const (
@@ -4598,7 +4641,7 @@ func verifyMetricsNonZero(names ...string) func(metrics map[string]*prompb.Metri
45984641
}
45994642
}
46004643

4601-
func verifyMetricsUnderThreshold(
4644+
func (ct *cdcTester) verifyMetricsUnderThreshold(
46024645
names []string, threshold float64,
46034646
) func(metrics map[string]*prompb.MetricFamily) (ok bool) {
46044647
namesMap := make(map[string]struct{}, len(names))
@@ -4622,6 +4665,8 @@ func verifyMetricsUnderThreshold(
46224665
observedValue := m.Histogram.GetSampleSum() / float64(m.Histogram.GetSampleCount())
46234666
if observedValue < threshold {
46244667
found[name] = struct{}{}
4668+
} else {
4669+
ct.t.Fatalf("observed value for metric %s over threshold. observedValue: %f, threshold: %f", name, observedValue, threshold)
46254670
}
46264671
}
46274672

pkg/workload/bank/bank.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ var bankMeta = workload.Meta{
7171
g.flags.IntVar(&g.numTables, `num-tables`, defaultNumTables, `Number of bank tables to create.`)
7272
RandomSeed.AddFlag(&g.flags)
7373
g.connFlags = workload.NewConnFlags(&g.flags)
74+
// Because this workload can create a large number of objects, the import
75+
// concurrent may need to be limited.
76+
g.flags.Int(workload.ImportDataLoaderConcurrencyFlag, 32, workload.ImportDataLoaderConcurrencyFlagDescription)
7477
return g
7578
},
7679
}

0 commit comments

Comments
 (0)