-
Notifications
You must be signed in to change notification settings - Fork 993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: configmgr need wait for all processed avoid tests data race #3891
Conversation
Welcome @zedongh! |
e352aa2
to
0ad0054
Compare
seems add a rwlock is enough: ) |
Agree! |
…be processed Signed-off-by: zedongh <248348907@qq.com>
Thanks a lot. After review the code of fake source, I make last simple commit in I believe there should be no concurrency here, so it is not suitable to use locks. The only scenario where concurrency occurs is as follows: Mgr.Start goroutine [Order 1] key, quit := queue.Get() // consume item and queue size -1
[Order 3a] m.notifyListeners() Test goroutine [Order 2]. s.Stop() // queue length is zero, break loop, queue Shutdown, but item not Done yet
// if f.queue.Len() == 0 {
// f.queue.ShutDown()
// return
// }
[Order 3b] assert.Equal(t, tc.expectedNotifyCalled, l.called) 3a and 3b have no order guarantee. may cause data race Simple to make origin test failed is set a time out in func (l *FakeListener) SyncConfig(cfg *api.ColocationConfig) error {
// time out will make this calling after testing assert, make it failed
// time.Sleep(1*time.Second + 500*time.Millisecond)
l.called++ |
As the issue described, |
Yeah, the reason is fakeSource |
/ok-to-test |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Monokaix The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I think we can merge it first, this is a reasoable change, if it still fails, we can re-work ion that. @lowang-bh |
/lgtm |
configmgr
Start
test need ensure all queue source be processed then doassert
action. avoid calll.called
when it write atSyncConfig
.@lowang-bh
/close #3884