makara icon indicating copy to clipboard operation
makara copied to clipboard

add sidekiq middleware component to avoid reusing contexts between wo…

Open pinnymz opened this issue 5 years ago • 4 comments

…rkers

pinnymz avatar Mar 26 '19 20:03 pinnymz

Related to #151, I have confirmed that context reuse between tasks is taking place on recycled threads. This PR will avoid leaking contexts of previous tasks by clearing out the context as a post-task operation.

pinnymz avatar Mar 26 '19 20:03 pinnymz

It would be great to get some eyes on this if it fixes the issue with Sidekiq workers!

I'll try to test it in our app where we're seeing ActiveRecord::ConnectionTimeoutError exceptions once I can reliably reproduce them locally.

sharang-d avatar Jan 11 '20 07:01 sharang-d

How do you manage to make Sidekiq work with read-replicas at all? Sidekiq jobs will usually fail because they start processing faster than the replica lag so the data the job has to work with will be missing or out of date unless Sidekiq connects directly to master. If you have a solution to that, I'd love to know!

Gargron avatar Jun 24 '20 12:06 Gargron

We pointed background workers always to the primary (writer) for this reason and that they often were doing updates anyway.

bleonard avatar Jul 28 '20 21:07 bleonard