We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When using threads, the tenant is not preserved:
irb(main):009:0> MultiTenant.current_tenant = 1 => 1 irb(main):010:0> puts "tenant_id: #{MultiTenant.current_tenant_id}" irb(main):011:0> thr = Thread.new { puts "tenant_id: #{MultiTenant.current_tenant_id}" } tenant_id: 1 => #<Thread:0x0000000148ff8388 (irb):11 run> tenant_id:
Hence queries don't have the tenant clasue and may leak data
irb(main):001:0> MultiTenant.current_tenant = 1 => 1 irb(main):002:0> puts Page.where(id: 999).to_sql irb(main):003:0> thr = Thread.new { puts Page.where(id: 999).to_sql } SELECT "pages".* FROM "pages" WHERE "pages"."customer_id" = 1 AND "pages"."id" = 999 => #<Thread:0x0000000149cfb198 (irb):3 run> irb(main):004:0> SELECT "pages".* FROM "pages" WHERE "pages"."id" = 999
In case this add extra info, we are using concurrent-ruby and we have the same issue
irb(main):002:0> MultiTenant.current_tenant = 1 => 1 irb(main):003:0> thread_pool = Concurrent::FixedThreadPool.new(2) => #<Concurrent::FixedThreadPool:0x00000001251130c0 ... irb(main):004:1* thread_pool.post do irb(main):005:1* puts "tenant_id: #{MultiTenant.current_tenant_id}" irb(main):006:0> end => true tenant_id:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When using threads, the tenant is not preserved:
Hence queries don't have the tenant clasue and may leak data
In case this add extra info, we are using concurrent-ruby and we have the same issue
The text was updated successfully, but these errors were encountered: