diff --git a/pkg/ccl/changefeedccl/changefeed_test.go b/pkg/ccl/changefeedccl/changefeed_test.go index 381bb7e3c6e2..cafa223c150c 100644 --- a/pkg/ccl/changefeedccl/changefeed_test.go +++ b/pkg/ccl/changefeedccl/changefeed_test.go @@ -1359,6 +1359,8 @@ func TestNoBackfillAfterNonTargetColumnDrop(t *testing.T) { func TestChangefeedColumnDropsWithFamilyAndNonFamilyTargets(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + testFn := func(t *testing.T, s TestServer, f cdctest.TestFeedFactory) { sqlDB := sqlutils.MakeSQLRunner(s.DB) diff --git a/pkg/ccl/changefeedccl/metrics.go b/pkg/ccl/changefeedccl/metrics.go index fd58de006791..cec7595cf8c6 100644 --- a/pkg/ccl/changefeedccl/metrics.go +++ b/pkg/ccl/changefeedccl/metrics.go @@ -741,10 +741,15 @@ func (s *sliMetrics) getLaggingRangesCallback() func(int64) { // If 3 ranges catch up, last=10,i=7: X.Dec(10 - 7) = X.Dec(3) // If 4 ranges fall behind, last=7,i=11: X.Dec(7 - 11) = X.Inc(4) // If 1 lagging range is deleted, last=7,i=10: X.Dec(11-10) = X.Dec(1) - var last int64 + last := struct { + syncutil.Mutex + v int64 + }{} return func(i int64) { - s.LaggingRanges.Dec(last - i) - last = i + last.Lock() + defer last.Unlock() + s.LaggingRanges.Dec(last.v - i) + last.v = i } }