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

[FIXED] Panic in ordered consumer #1686

Merged
merged 3 commits into from
Aug 1, 2024
Merged

Conversation

piotrpio
Copy link
Collaborator

Signed-off-by: Piotr Piotrowski [email protected]

zonque and others added 3 commits July 25, 2024 10:29
In `orderedConsumer.reset()`, `retryWithBackoff()` is returned from with
`false, nil` in case the subscription is closed. In this case,
`var cons Consumer` is still `nil`, and the code crashes in the attempt to
cast it to a `pullConsumer` later on.

Fix this by catching the `nil` case explicitly.

Signed-off-by: Daniel Mack <[email protected]>
Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

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

LGTM,

one question to make sure its ok.

@@ -142,6 +145,9 @@ func (c *orderedConsumer) Consume(handler MessageHandler, opts ...PullConsumeOpt
select {
case <-c.doReset:
if err := c.reset(); err != nil {
if errors.Is(err, errOrderedConsumerClosed) {
Copy link
Member

Choose a reason for hiding this comment

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

The only case for errOrderedConsumerClosed is when its stopped, so there is no point to try resetting it again, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, there is no point. I used continue here because when the consumer is stopped we'll eventually end up in <-sub.done case where the actual cleanup is performed.

@piotrpio piotrpio merged commit 5e0a59b into main Aug 1, 2024
4 checks passed
@piotrpio piotrpio deleted the fix-ordered-consumer-nil-pointer branch August 1, 2024 10:50
@piotrpio piotrpio mentioned this pull request Aug 13, 2024
piotrpio added a commit that referenced this pull request Aug 15, 2024
Signed-off-by: Piotr Piotrowski <[email protected]>
Co-authored-by: Daniel Mack <[email protected]>
piotrpio added a commit that referenced this pull request Aug 15, 2024
Signed-off-by: Piotr Piotrowski <[email protected]>
Co-authored-by: Daniel Mack <[email protected]>
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.

3 participants