-
Notifications
You must be signed in to change notification settings - Fork 328
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
[actsync] Fix data race #4456
[actsync] Fix data race #4456
Conversation
Quality Gate passedIssues Measures |
@@ -95,7 +95,6 @@ func (as *ActionSync) Stop(ctx context.Context) error { | |||
return err | |||
} | |||
close(as.quit) | |||
close(as.syncChan) |
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.
do not close the channel, so it will not panic.
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.
better to close the channel, otherwise we are leaving a channel that may still have data (and possibly a memory leak)
can send to another chan in sync(), and wait that channel here, then close syncChan
<- as.exit
close(as.syncChan)
log.L().Warn("Failed to request action from neighbors", zap.Error(err)) | ||
counterMtc.WithLabelValues("failed").Inc() | ||
} | ||
case <-as.quit: |
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.
quit immediately may cause data discard, but it should be acceptable when stop service
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.
have another channel and close it here, so Stop()
can receive from this channel, and continue close the service
as.exit <- struct{}{}
log.L().Info("quitting action sync")
return
add unit tests for the fix |
Quality Gate failedFailed conditions |
Description
Fixes #4399
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: