-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
provider problem in multi threaded condition #272
Comments
Can you please explain why you load a provider lazily? I think I haven't stumbled upon this problem because I load my app eagerly. |
Hi @flash-gordon, we now finalize the container in production, but still want to lazy load in development and other non production environment for performance gain |
I think you should be safe with your approach, I also use puma in dev mode without eager loading but I haven't encountered the issue. |
we didn't encounter the issue until recently whenever there's intensive high traffic in a small time period, and it is happening more during the moment of rolling update when puma receives heavy request hit upon fresh start/restarted worker |
FWIW, I think this would be good to actually make threadsafe, and would certainly welcome PRs for this :) |
Seems like lazy-registration is not thread-safe, yeah? Resolving is supposed to be thread-safe because dry-container is. It should be relatively easy to fix it in the AutoRegistrar. |
At the same time, an app is kind of expected to be fully loaded in production. Currently, we don't have a standard way to tell a dry-system container which "environment" it operates in. If we had it, it'd be possible to load the app in production eagerly by default with an option to opt out. |
Describe the bug
when using dry-system in multi threaded platform, i.e. puma.
when lazy loading provider
there's race condition in the provider start block
in our production environment, we are getting key not found error when calling
Container['path.to.key
]`we tried to replicate the exact issue we are having by putting a new spec in this repo(as shown below), but all we can see is warning of circular require(as shown in the stacktrace below)
the warning kinda illustrated the problem.
To Reproduce
spec put in
spec/integration/providers/resolving_root_key_spec.rb
Expected behavior
Expected running(or triggering) of the provider steps are thread safe
My environment
The text was updated successfully, but these errors were encountered: