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

fix: redis requeue concurrency bug #1800 #1805

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion kombu/transport/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ def ack(self, delivery_tag):
def reject(self, delivery_tag, requeue=False):
if requeue:
self.restore_by_tag(delivery_tag, leftmost=True)
self.ack(delivery_tag)
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be great if you could add unit test for this change and if possible, integration test which will give us a lot of confidence

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be great if you could add unit test for this change and if possible, integration test which will give us a lot of confidence

self._remove_from_indices(delivery_tag).execute()
super().ack(delivery_tag)

@contextmanager
def pipe_or_acquire(self, pipe=None, client=None):
Expand Down
11 changes: 9 additions & 2 deletions t/unit/transport/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1521,9 +1521,16 @@ def test_get_no_actions(self):
def test_qos_reject(self):
p, channel = self.create_get()
qos = redis.QoS(channel)
qos.ack = Mock(name='Qos.ack')
qos._remove_from_indices = Mock(name='_remove_from_indices')
qos.reject(1234)
qos.ack.assert_called_with(1234)
qos._remove_from_indices.assert_called_with(1234)

def test_qos_requeue(self):
p, channel = self.create_get()
qos = redis.QoS(channel)
qos.restore_by_tag = Mock(name='restore_by_tag')
qos.reject(1234, True)
qos.restore_by_tag.assert_called_with(1234, leftmost=True)

def test_get_brpop_qos_allow(self):
p, channel = self.create_get(queues=['a_queue'])
Expand Down