Skip to content

Conversation

@davydovmax
Copy link
Contributor

@davydovmax davydovmax commented Sep 19, 2017

Fixed consumer getting stuck in acquire() after item is explicitly ignored

Without a fix, if we encounter this scenario, we will get an infinite loop in acquire():

  1. start consuming
  2. explicitly ignore() any item
  3. continue consuming
  4. wait till reset() is called (queue is exhausted or consume() called again)
  5. try consume more items
  6. acquire() receives already ignored item
    7. item is ignored but $self->{last_id} is not updated
    8. we skip item and loop back to 6, where process same item again

Fix just updates $self->{last_id} when we skip an ignored item. This
logic is similar to original logic in Data::Consumer::MySQL.

Also added test case for this scenario.

…nored

Without a fix, if we encounter this scenario, we will get an infinite loop in acquire():
1. start consuming
2. explicitly ignore() any item
3. continue consuming
4. wait till reset() is called (queue is exhausted or consume() called again)
4. try consume more items
5. acquire() receives already ignored item
    6. item is ignored but $self->{last_id} is not updated
    7. we skip item and loop back to demerphq#5, where process same item again

Fix just updates $self->{last_id} when we skip an ignored item. This
logic is similar to original logic in Data::Consumer::MySQL.
@demerphq demerphq merged commit 02c50db into demerphq:master Nov 1, 2017
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