br/pkg/streamhelper: fix flaky TestGCServiceSafePoint assertion (#66755)#66889
br/pkg/streamhelper: fix flaky TestGCServiceSafePoint assertion (#66755)#66889ti-chi-bot wants to merge 2 commits intopingcap:release-8.5from
Conversation
📝 WalkthroughWalkthroughThis PR addresses a flaky test by adding explicit state tracking to the test infrastructure. A new Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.5.0)Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
br/pkg/streamhelper/advancer_test.go (1)
210-213: Minor: Locking consistency.Line 210 reads
serviceGCSafePointwithout the mutex, while lines 211-213 acquire the lock forserviceGCSafePointSet. Since both fields are protected by the same mutex inBlockGCUntil, consider consolidating both reads under a single lock for consistency:♻️ Optional: Consolidate assertions under lock
req.NoError(adv.OnTick(ctx)) - req.Equal(env.serviceGCSafePoint, cp-1) env.fakeCluster.mu.Lock() + req.Equal(env.serviceGCSafePoint, cp-1) req.True(env.serviceGCSafePointSet) env.fakeCluster.mu.Unlock()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@br/pkg/streamhelper/advancer_test.go` around lines 210 - 213, The test reads env.serviceGCSafePoint without holding the cluster mutex while later assertions lock env.fakeCluster.mu; to make locking consistent, acquire env.fakeCluster.mu before reading env.serviceGCSafePoint and keep the check of env.serviceGCSafePointSet inside the same critical section (i.e., wrap the req.Equal(env.serviceGCSafePoint, cp-1) and req.True(env.serviceGCSafePointSet) under a single env.fakeCluster.mu.Lock()/Unlock() block), matching how BlockGCUntil protects those fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@br/pkg/streamhelper/advancer_test.go`:
- Around line 210-213: The test reads env.serviceGCSafePoint without holding the
cluster mutex while later assertions lock env.fakeCluster.mu; to make locking
consistent, acquire env.fakeCluster.mu before reading env.serviceGCSafePoint and
keep the check of env.serviceGCSafePointSet inside the same critical section
(i.e., wrap the req.Equal(env.serviceGCSafePoint, cp-1) and
req.True(env.serviceGCSafePointSet) under a single
env.fakeCluster.mu.Lock()/Unlock() block), matching how BlockGCUntil protects
those fields.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 51e25915-e1eb-49e6-9336-0f35d4887a7f
📒 Files selected for processing (2)
br/pkg/streamhelper/advancer_test.gobr/pkg/streamhelper/basic_lib_for_test.go
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-8.5 #66889 +/- ##
================================================
Coverage ? 55.5390%
================================================
Files ? 1819
Lines ? 652779
Branches ? 0
================================================
Hits ? 362547
Misses ? 263318
Partials ? 26914
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Leavrth, YuJuncen The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
This is an automated cherry-pick of #66755
What problem does this PR solve?
Issue Number: close #66731
Problem Summary:
TestGCServiceSafePointinbr/pkg/streamhelperis flaky because it waits forserviceGCSafePoint != 0after task removal. In this test setup,cpcan be1, socp-1is validly0, causing intermittent false failures.What changed and how does it work?
TestGCServiceSafePointto wait only forserviceGCSafePointDeletedafter unregistering the task.serviceGCSafePoint == cp-1, so the safe point value is still verified.This removes the nondeterministic
!= 0condition while preserving the intended behavior checks.Check List
Tests
Side effects
Documentation
Release note
Summary by CodeRabbit