Open bubiche opened 2 weeks ago
Ohhh, totally! Let me look into this one to see how to fix, I think it's something Solid Queue should handle. Thanks for the report!
Same issue here. is there a workaround? my entire controller is in a connected_to
block?
I tried wrapping the perform_later in another connection switch but no luck.
ActiveRecord::Base.connected_to(role: :writing, shard: :queue) do
Workers::Foobar.perform_later(account_id: account_id, id: id)
end
My rails application connects to multiple databases with the configs below:
database.yml
``` production: primary_shard: ... secondary_shard: ... queue: ... ```config/initializers/database.rb
```ruby # This is needed due to us using another gem whose model writes to both primary_shard and secondary_shard and its model inherits from ActiveRecord::Base ActiveRecord::Base.instance_eval do connects_to shards: { primary_shard: { writing: :primary_shard, }, secondary_shard: { writing: :secondary_shard, }, } end ```SolidQueue
has been working well, the only time where we cannot enqueue is if we have a block of code like below:I think it is because
SolidQueue
is trying to insert the job intosecondary_shard
instead of thequeue
database. Is there any way to circumvent this besides rewriting the code to callperform_later
outside of theconnected_to
block?SomeJob.perform_later
might be called inside a function with theconnected_to
block so it's quite a big refactor for us.