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

Thread safety #142

Open
MmKolodziej opened this issue Nov 28, 2017 · 2 comments
Open

Thread safety #142

MmKolodziej opened this issue Nov 28, 2017 · 2 comments
Milestone

Comments

@MmKolodziej
Copy link

Overall, thread safety is really a big issue in this gem. Which, you could argue is "okish", since fails can be returned only when one of racing checks returns a false.

I've only been using a few checks and I've noticed a rather big issue with GenericCacheCheck though. When 2 checks hit a multi threaded application, the values saved in the key shared by both threads will be random, which will very likely cause a fail when reading them back. I am solving this temporarily with a mutex, since I am not sure whether you'd prefer to generate a more unique key (which could potentially lead to things being left over in a cache store) or a mutex.

@pbyrne
Copy link
Collaborator

pbyrne commented Nov 28, 2017

I'll admit that thread safety really hasn't been something I've paid much attention to with this gem, since I primarily use Uncorn (process-based vs thread-based). Mutexes feel reasonable to me as a moderate-impact solution with the way the app is written now.

Rewriting the engine to instantiate fresh instances of the checks with each request also feel reasonable (and would also eliminate some of the grossness around clearing state when starting a new set of checks). It's unclear to me how tough that would be to accomplish in a backward-compatible way.

@johnnyshields
Copy link
Contributor

This should be in-scope for 2.0

@anfleene anfleene added 2.0 Features for 2.0 and removed 2.0 Features for 2.0 labels Jan 9, 2019
@anfleene anfleene added this to the v2.0 milestone Jan 9, 2019
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

4 participants