Skip to content

Commit 4d8e356

Browse files
committed
changefeedccl: limit bank transfers in TestCatchupScanOrdering
TestCatchupScanOrdering validates changefeed ordering by having one goroutine that makes bank transfers continuously and another goroutine that validates the order in which events are received downstream. This change limits the number of bank transfers before exiting the first goroutine to 2x the number expected downstream for a successful test run. The goal is to not have a goroutine that is doing busy work that might hog CPU. Epic: none Fixes: #148565 Release note: none
1 parent 923e3b0 commit 4d8e356

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pkg/ccl/changefeedccl/validations_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"time"
1515

1616
"github.com/cockroachdb/cockroach/pkg/ccl/changefeedccl/cdctest"
17-
"github.com/cockroachdb/cockroach/pkg/ccl/utilccl"
1817
"github.com/cockroachdb/cockroach/pkg/util/ctxgroup"
1918
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
2019
"github.com/cockroachdb/cockroach/pkg/util/log"
@@ -26,12 +25,12 @@ import (
2625
func TestCatchupScanOrdering(t *testing.T) {
2726
defer leaktest.AfterTest(t)()
2827
defer log.Scope(t).Close(t)
29-
defer utilccl.TestingEnableEnterprise()()
3028

3129
testFn := func(t *testing.T, s TestServer, f cdctest.TestFeedFactory) {
3230
t.Run("bank", func(t *testing.T) {
3331
ctx := context.Background()
3432
const numRows, numRanges, payloadBytes, maxTransfer = 10, 10, 10, 999
33+
const checkRows = 200
3534
gen := bank.FromConfig(numRows, numRows, payloadBytes, numRanges)
3635
var l workloadsql.InsertsDataLoader
3736
if _, err := workloadsql.Setup(ctx, s.DB, gen, l); err != nil {
@@ -62,7 +61,7 @@ func TestCatchupScanOrdering(t *testing.T) {
6261
g.GoCtx(func(ctx context.Context) error {
6362
prevTimeTransfer := time.Now()
6463
for {
65-
if atomic.LoadInt64(&done) > 0 {
64+
if atomic.LoadInt64(&done) > 0 || numOfTrans.Load() > 2*checkRows {
6665
return nil
6766
}
6867
if err := randomBankTransfer(numRows, maxTransfer, s.DB); err != nil {
@@ -95,7 +94,7 @@ func TestCatchupScanOrdering(t *testing.T) {
9594
t.Logf("key: %s, value: %s\n", m.Key, m.Value)
9695
t.Logf("time taken to see the %d-th changefeed change: %v", seenChanges, time.Since(prevTimeCDC))
9796
prevTimeCDC = time.Now()
98-
if seenChanges >= 200 {
97+
if seenChanges >= checkRows {
9998
atomic.StoreInt64(&done, 1)
10099
break
101100
}

0 commit comments

Comments
 (0)