Open alpaca-tc opened 8 months ago
Ruby can potentially cause deadlocks when loading code with multi-threading. And in our project, this deadlock was occurring. https://github.com/rails/rails/issues/50802
Part of the reason for this was that the gem was making constant load to Tenant
in any multi-tenantized model.
Hopefully this PR will be merged.
The basic policy of Rails is that application code in the development environment is lazy loaded. For this reason,
class_name
is passed as a string rather than a class in the reflection definition, and the string is not constantized until it is evaluated. This is done to reduce performance issues and the complex locking load of constant-loading logic.Now activerecord-multitenant is loading the class specified in the argument to multi_tenant() without lazy loading. This conditional statement was added at https://github.com/citusdata/activerecord-multi-tenant/pull/6, but I have been fixed. Note that for projects where the tenant model does not exist, the existing behavior is supported by specifying
skip_reflection: true
.