-
Notifications
You must be signed in to change notification settings - Fork 42
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
ISSUE#195 github.com/spf13/viper is not thread safe #246
Conversation
fb3ea8f
to
c858b19
Compare
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.
Looks promising. We need unit tests for core/viper
. What about reading in various 0chain config files, writing them out then rereading them? Then checking it worked.
We also want to test concurrency, so maybe run several tests in parallel that modify the viper store, in a similar way to 0chain, and confirm it can cope.
@Sriep |
Do we use any of the non-thread-safe methods? Yes AddConfigPath and SetConfigType. Eye on the goal: We don't want race errors. So either avoid using unsafe viper methods or make sure they are only accessed from one thread. |
I think we just have to let the non-thread-safe methods stand. Assume they are always called safely. We can then raise a separate issue to check our usage of non-thread-safe viper methods and, if necessary, fix that in a separate PR. |
- add tests that Viper is thread safe
- remove non thread safe methods
- fix error core/viper/viper.go:261: undefined: os.ReadFile note: module requires Go 1.15
There is a suggestion to solve the problem with the Viper package using wrapper functions. Let's discuss this.