-
-
Notifications
You must be signed in to change notification settings - Fork 262
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.Current storage under unicorn/thin #34
Comments
Is this related to race conditions? |
Only if you aren't guaranteed to set a tenant in each request. In my case I had two namespaced sections of the site, one which guaranteed a tenant was set and one which didn't. The section not setting a tenant would often throw errors because a tenant was still set when it shouldn't have been (and hadn't been during that request). I now explicitly set the tenant to nil on the non-tenant section. |
I read the SO post. Interesting stuff. I'm thinking of clearing the @toxaq In the app you are talking about in your comment: on the section without the tenant set, is the code still passing through the tenant assignment in |
Yeah, I'm using the before filter approach. I only set it if required, so it effectively skipped the setting. Setting to nil explicitly works fine (my fix). |
I've switched the gem (master) to using request_store instead of Thread.current. This should ensure a clean slate for each request. @toxaq If you could find the time to test if this indeed fixes the issues you were experiencing (without your later fixes), that would be much appreciated! |
Just caught up on this, will try a test this week and see how I go. Thanks for the update! |
@toxaq Were you ever able to determine the issue and what resolved it? |
@swordfish444 it's a long time ago now but I think Erwin's change to request_store resolved this but explicitly setting on every request in a before_filter also worked adequately. |
When using
thin
orunicorn
Thread.Current isn't guaranteed to be cleared between requests, so you could end up having a tenant set when you don't want it set. As per this SO QuestionThere seems to be two solutions here:
Thoughts?
The text was updated successfully, but these errors were encountered: