You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using activerecord-multi-tenant with the paid Sidekiq-Pro gem, sidekiq batch callbacks do not have a tenant set by default, even if the original job and batch were enqueued inside a tenant block.
You will find that while the tenant is set correctly in perform, it is not set in callback. This is because of a middleware ordering issue between the multitenant code and the sidekiq-pro batch code.
We were able to work around this issue by manually removing and re-ordering the middleware in our own initializer:
# Fix middleware order so that Sidekiq Batch Callbacks are run with a tenant setchain.remove(Sidekiq::Middleware::MultiTenant::Client)chain.insert_before(Sidekiq::Batch::Client,Sidekiq::Middleware::MultiTenant::Client)
(and the same thing for the server middleware, and the client middleware on the server).
Given that this is a sidekiq-builtin feature, it would be nice if this gem could check for the presence of the Batch middleware and insert its middleware in the correct spot by default.
The text was updated successfully, but these errors were encountered:
When using
activerecord-multi-tenant
with the paid Sidekiq-Pro gem, sidekiq batch callbacks do not have a tenant set by default, even if the original job and batch were enqueued inside a tenant block.Given the following example job:
and the following execution (assuming
1
is a valid tenant ID):You will find that while the tenant is set correctly in
perform
, it is not set incallback
. This is because of a middleware ordering issue between the multitenant code and the sidekiq-pro batch code.We were able to work around this issue by manually removing and re-ordering the middleware in our own initializer:
(and the same thing for the server middleware, and the client middleware on the server).
Given that this is a sidekiq-builtin feature, it would be nice if this gem could check for the presence of the Batch middleware and insert its middleware in the correct spot by default.
The text was updated successfully, but these errors were encountered: