-
Notifications
You must be signed in to change notification settings - Fork 14
Guard viper configuration with RWLock #1232
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
Conversation
|
It is hard to tell, but I am fairly sure that if this fixed the problem. I could re-produce it once more without these changes (took a lot of tries), but now it does not seem to happen anymore... |
internal/analytics/deferred.go
Outdated
| if err != nil { | ||
| return errs.Wrap(err, "Could not load events on send") | ||
| } | ||
| if len(deferred) == 0 { |
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.
Suggestion: It might be worth, instead, using if len(deferred) > 0 and placing it around the cfg.Save below so that the "deferrerFilePath" is cleaned up.
| for n, event := range deferred { | ||
| if err := sender(event.Category, event.Action, event.Label, event.Dimensions); err != nil { | ||
| return errs.Wrap(err, "Could not send deferred event") | ||
| if len(deferred) > 0 { |
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.
Nit: This is an unnecessary change.
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.
It skips the save of the configuration file, which I believe should be avoided if nothing changed. Of course, it doesn't affect this bug, but as we have seen that viper also has issues with concurrent writes between processes...
https://www.pivotaltracker.com/story/show/176721598