wireframe / multitenant

making cross tenant data leaks a thing of the past.
http://blog.codecrate.com/2011/03/multitenant-locking-down-your-app-and.html
MIT License
164 stars 36 forks source link

Thread safety #4

Open ledermann opened 13 years ago

ledermann commented 13 years ago

IMHO, using

attr_accessor :current_tenant

is not thread-safe. You should use

Thread.current[:current_tenant]

instead.

priithaamer commented 13 years ago

Can someone confirm this? I've been using acts_as_scoped in Rails 2.3 app over several years now. This plugin also uses attr_accessor to store the "current" scope object and it has been working fine so far.

plentz commented 12 years ago

I pretty much dislike threadlocals, but I think that this is a good use.

HakubJozak commented 6 years ago

Hi! Is anyone still maintaining this gem? I really think it is thread-safe and anyone using it in production in multi-threaded env should be warned. Here is a quick test:

https://gist.github.com/HakubJozak/b00d577f1703ba28dc3cff1aec514626

wireframe commented 6 years ago

hey @HakubJozak, thanks for putting together the demo script and I'd be happy to fix any known issues. would you be interested in putting together a pull request to close this issue?

sapanakothari commented 3 years ago

@wireframe PR to make multitenant thread-safe https://github.com/wireframe/multitenant/pull/19