-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
ActiveJobExtensions clobbers Sidekiq tenancy #328
Comments
I think def deserialize(job_data)
tenant_global_id = job_data.delete("current_tenant")
ActsAsTenant.current_tenant = tenant_global_id ? GlobalID::Locator.locate(tenant_global_id) : nil
super
end Should become def deserialize(job_data)
tenant_global_id = job_data.delete("current_tenant")
tenant = tenant_global_id ? GlobalID::Locator.locate(tenant_global_id) : nil
ActsAsTenant.with_tenant tenant do
super
end
end |
Implements the suggestion from ErwinM#328 (comment)
Implements the suggestion from ErwinM#328 (comment)
@tmaier I've attempted your suggestion to resolve my issues losing Thinking through the change, I don't think I think the underlying issue with the ActiveJobExtensions implementation is still a problem and would benefit from the improvements suggested by @atcruice. I'm planning to spend a little more time thinking through this and #335 and then hopefully submit a PR. 💭 |
We recently encountered some difficulty trying to update to v1. The cause is an undesirable interaction between
ActsAsTenant::Sidekiq::Server
and the newActsAsTenant::ActiveJobExtensions
(introduced in #319) - due to their different tenancy control approaches:Context
We use a rolling deploy strategy, so have both old and new code in active use for a period during release. The exceptions we encountered were due to:
ActsAsTenant::ActiveJobExtensions#serialize
(missing the"current_tenant"
key)ActsAsTenant::Sidekiq::Client#call
saving job tenancy in"acts_as_tenant"
hashActsAsTenant::Sidekiq::Server#call
setting job tenancy from"acts_as_tenant"
hashActsAsTenant::ActiveJobExtensions#deserialize
then nullifyingActsAsTenant.current_tenant
because the"current_tenant"
key was absent (clobbering the existing tenancy context)Proposed Solution
I'd like to work on refactoring
ActsAsTenant::ActiveJobExtensions#deserialize
such that:ActsAsTenant.current_tenant
is already setDo these sound like reasonable improvements?
The text was updated successfully, but these errors were encountered: