Skip to content

[Redis broker] message_refc dips into negative numbers on ConnectionError #262

Closed
benekastah wants to merge 3 commits intoBogdanp:masterfrom
Pathlight:bug/redis-consumer-message_refc
Closed

[Redis broker] message_refc dips into negative numbers on ConnectionError #262
benekastah wants to merge 3 commits intoBogdanp:masterfrom
Pathlight:bug/redis-consumer-message_refc

Conversation

@benekastah
Copy link
Copy Markdown
Contributor

This can cause prefetching too many messages. The reason is that when we
try to call consumer.ack or consumer.nack, and a ConnectionError
happens, we will retry. But each time we retry, we decrement message_refc
again. Solved this by using a set to track queued messages, so calling ack
or nack on the same message doesn't mess up our accounting.

This can cause prefetching too many messages. The reason is that when we
try to call `consumer.ack` or `consumer.nack`, and a `ConnectionError`
happens, we will retry. But each time we retry, we decrement `message_refc`
again. Solved this by using a set to track queued messages, so calling `ack`
or `nack` on the same message doesn't mess up our accounting.
self.misses = 0

@property
def message_refc(self):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This property is so I can use the same test code with this version of the file and with the previous version of the file.

@benekastah benekastah changed the title message_refc dips into negative numbers on ConnectionError [Redis broker] message_refc dips into negative numbers on ConnectionError Jan 9, 2020
# prefetch up to that number of messages.
messages = []
num_messages = len(self.queued_message_ids)
if self.message_refc < self.prefetch:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Seems like this is a bug since message_refc has been removed. Did you mean to use num_messages here?

@Bogdanp
Copy link
Copy Markdown
Owner

Bogdanp commented Jan 20, 2020

I made a couple changes here and merged this into master with rebase. Thanks for the fix!

@Bogdanp Bogdanp closed this Jan 20, 2020
@Bogdanp Bogdanp added this to the v1.8.0 milestone Jan 20, 2020
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