Skip to content
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

Feature/fix on conflict handling #1

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

dsander
Copy link
Member

@dsander dsander commented Sep 15, 2021

Debugging CI failures

@dsander dsander force-pushed the feature/fix-on-conflict-handling branch 2 times, most recently from d1762f9 to e1610b5 Compare September 15, 2021 11:12
* Necessary upgrades for Sidekiq v6.2.2

* Adds some coverage for the Sidekiq::Job scenario

* Mandatory rubocop commit

* Remove a number of gems I never user

Also, install gems only when on Mac (prevents additional gems on CI)

* Mandatory rubocop commit
@dsander dsander force-pushed the feature/fix-on-conflict-handling branch from e1610b5 to f7cce0e Compare September 26, 2021 09:27
This fixes the exception posted below when using `on_conflict: replace`
and potentially other bugs related to `on_conflict`. Before [this change][1]
`BasicLock.lock` always returned either the acquired lock or the return
value of `call_strategy`. Since `Middleware::Client#lock` now only
yields when `lock_instance.lock` yields we have to also `yield` inside
the lock instances when the lock was acquired via `lock_failed` (i.e. a
`on_conflict` strategy).

```
NoMethodError: undefined method `key?' for "f5d69f8fd2e1f3dde8cee02e":String
  from sidekiq/client.rb:197:in `atomic_push'
  from sidekiq/client.rb:190:in `block (2 levels) in raw_push'
  from redis.rb:2489:in `block in multi'
  from redis.rb:69:in `block in synchronize'
  from monitor.rb:202:in `synchronize'
  from monitor.rb:202:in `mon_synchronize'
  from redis.rb:69:in `synchronize'
  from redis.rb:2483:in `multi'
  from sidekiq/client.rb:189:in `block in raw_push'
  from connection_pool.rb:63:in `block (2 levels) in with'
  from connection_pool.rb:62:in `handle_interrupt'
  from connection_pool.rb:62:in `block in with'
  from connection_pool.rb:59:in `handle_interrupt'
  from connection_pool.rb:59:in `with'
  from sidekiq/client.rb:188:in `raw_push'
  from sidekiq/client.rb:74:in `push'
  from sidekiq/worker.rb:240:in `client_push'
  from sidekiq/worker.rb:215:in `perform_in'
```

 mhenrixon#590

[1]: s://github.com/mhenrixon/sidekiq-unique-jobs/commit/8c8d54c8b9dea363a7d8b8aeaceb2e82966b8503
When using the `on_conflict` `replace` strategy `base_lock` has to
return the return value of the conflict strategy. The replace strategy
removes the previous job from the scheduled/rety set or the queue.
It is then re-queued inside `lock_failed`/`call_strategy`, thus we have
to return the return value of which came from `lock` inside the block of
` client_strategy.call`.
@dsander dsander force-pushed the feature/fix-on-conflict-handling branch from 31195e9 to b3255e1 Compare September 26, 2021 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants