Skip to content
This repository was archived by the owner on May 25, 2018. It is now read-only.
This repository was archived by the owner on May 25, 2018. It is now read-only.

Deadlock/Lock when executing too many concurrent similar jobs #3

@felipeclopes

Description

@felipeclopes

My application have a high volume of messages, and my jobs have this pattern:

ConvertMyMessageWorker.as_promise(message['id']).then do
    PersistToDBWorker.perform_async(message['id'])
end

So when the system starts queuing messages, it may happen that it got n enqueued ConvertMyMessageWorker where n is the total amount of Sidekiq concurrency.

When that happens, the next jobs to be enqueued try to get a connection from Redis pool and we got an exception similar to the following one:

2014-06-24T04:22:48Z 26045 TID-oxt24qbl0 WARN: Waited 5 sec
2014-06-24T04:22:48Z 26045 TID-oxt24qbl0 WARN: /Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/connection_pool-2.0.0/lib/connection_pool/timed_stack.rb:42:in `block (2 levels) in pop'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/connection_pool-2.0.0/lib/connection_pool/timed_stack.rb:34:in `loop'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/connection_pool-2.0.0/lib/connection_pool/timed_stack.rb:34:in `block in pop'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/connection_pool-2.0.0/lib/connection_pool/timed_stack.rb:33:in `synchronize'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/connection_pool-2.0.0/lib/connection_pool/timed_stack.rb:33:in `pop'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/connection_pool-2.0.0/lib/connection_pool.rb:69:in `checkout'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/connection_pool-2.0.0/lib/connection_pool.rb:56:in `with'
/Users/felipeclopes/projects/sidekiq-promise/lib/sidekiq/promise/middleware.rb:24:in `publish_message'
/Users/felipeclopes/projects/sidekiq-promise/lib/sidekiq/promise/middleware.rb:20:in `job_errored'
/Users/felipeclopes/projects/sidekiq-promise/lib/sidekiq/promise/server_middleware.rb:15:in `rescue in call'
/Users/felipeclopes/projects/sidekiq-promise/lib/sidekiq/promise/server_middleware.rb:6:in `call'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/middleware/server/retry_jobs.rb:62:in `call'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/logging.rb:22:in `with_context'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/middleware/server/logging.rb:7:in `call'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/middleware/chain.rb:127:in `call'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/middleware/chain.rb:127:in `invoke'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/processor.rb:51:in `block in process'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/processor.rb:94:in `stats'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/sidekiq-3.1.4/lib/sidekiq/processor.rb:50:in `process'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/celluloid-0.15.2/lib/celluloid/calls.rb:122:in `dispatch'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
/Users/felipeclopes/.rvm/gems/ruby-2.1.2/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'

Do you have any idea for a workaround or a fix to this issue?

Regards,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions