multitenant icon indicating copy to clipboard operation
multitenant copied to clipboard

Thread safety

Open ledermann opened this issue 13 years ago • 5 comments

IMHO, using

attr_accessor :current_tenant

is not thread-safe. You should use

Thread.current[:current_tenant]

instead.

ledermann avatar May 31 '11 13:05 ledermann

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.

priithaamer avatar Aug 24 '11 12:08 priithaamer

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

plentz avatar Dec 08 '11 02:12 plentz

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

HakubJozak avatar Dec 01 '17 08:12 HakubJozak

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?

wireframe avatar Dec 05 '17 02:12 wireframe

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

sapanakothari avatar Apr 21 '21 10:04 sapanakothari