-
Notifications
You must be signed in to change notification settings - Fork 972
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 race condition issue #391
Fix race condition issue #391
Conversation
@@ -253,6 +253,7 @@ func (cc *Controller) syncJob(jobInfo *apis.JobInfo, updateStatus state.UpdateSt | |||
|
|||
waitCreationGroup := sync.WaitGroup{} | |||
waitCreationGroup.Add(len(podToCreate)) | |||
stateMutex := sync.Mutex{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move mutex into function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
classifyAndAddUpPodBaseOnPhase
is not the only place that we need to protect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the other also should move to function, do not put mutex in more than on place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI:
// A Mutex must not be copied after first use.
So this is not right, you can change to stateMutex := &sync.Mutex{}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hzxuzhonghu just curious, for which reason why this is not working? Which code leads to the multiple copies of mutex instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this var is used by many go routines, and if you print the address of it in the go routines, you can find they are not same. So can not protect the critical-section using different lock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the mutex instance is not used as a parameter for those go routines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense, my memory messed up.
07c5adb
to
5c44771
Compare
Hey @TommyLike, TravisCI finished with status TravisBuddy Request Identifier: 07b62a00-b1d5-11e9-9ed2-8f218eb7efe2 |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: k82cn, TommyLike 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 |
/lgtm |
@asifdxtreme what's the command to retest the patch? /retest |
For #359