Skip to content
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

config.Config is not safe because of config.Reload() being used in a signal handler. #218

Open
sjmudd opened this issue Jun 22, 2016 · 2 comments

Comments

@sjmudd
Copy link
Contributor

sjmudd commented Jun 22, 2016

You use config.Reload() based on signal handler activity to reload the configuration.

However other parts of the code may be reading config.Config.SomeVariable and as far as I can see there is no locking to prevent this so there's a race condition which is dangerous.

I noticed this adding some code to make some of the timer configuration dynamic, picked up by a SIGHUP, where as now these values are not modified even if the configuration is reloaded and this was pointed out by a colleague.

I've not looked to resolve this as the pattern of using config.Config.SomeSetting is very heavily used and to protect against corruption is likely to be quite intrusive so would like to see how this can be addressed.

@shlomi-noach
Copy link
Contributor

Confirmed, this makes a race condition.

@dgryski
Copy link
Contributor

dgryski commented Jun 27, 2016

The easiest solution to this is probably to store the configuration in an https://golang.org/pkg/sync/atomic/#Value .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants