Skip to content

fix(consumer): fix panic when messages size is 0#1460

Merged
RobertIndie merged 3 commits intoapache:masterfrom
unJASON:FIX1454
Mar 20, 2026
Merged

fix(consumer): fix panic when messages size is 0#1460
RobertIndie merged 3 commits intoapache:masterfrom
unJASON:FIX1454

Conversation

@unJASON
Copy link
Copy Markdown
Contributor

@unJASON unJASON commented Jan 22, 2026

Fixes #1454

Modifications

Describe the modifications you've done.

if messages in MessageReceived are all skipped, then don't add into queuech.

avoid panic when dispatcher() received clear command from clearQueueCh

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): no
  • The public API: no
  • The schema: don't know
  • The default values of configurations: no
  • The wire protocol: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? (not applicable / docs / GoDocs / not documented)
  • If a feature is not applicable for documentation, explain why?
  • If a feature is not documented yet in this PR, please create a followup issue for adding the documentation

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a panic in the consumer when all messages in a batch are filtered/skipped, resulting in an empty message slice being sent to the dispatcher. The panic occurred in the dispatcher() function when trying to access the first element of an empty slice during queue clearing operations.

Changes:

  • Added a check to prevent empty message slices from being sent to queueCh when all messages are filtered
  • Added a warning log when all messages in a batch are filtered

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pulsar/consumer_partition.go
Copy link
Copy Markdown
Member

@RobertIndie RobertIndie left a comment

Choose a reason for hiding this comment

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

Could you help add a test?

@unJASON unJASON requested a review from RobertIndie February 2, 2026 00:59
@unJASON
Copy link
Copy Markdown
Contributor Author

unJASON commented Feb 2, 2026

I'm truly sorry, but I really don't have an ample amount of time at the moment. You see, it seems to me that the situation is quite evident. In fact, the modifications required are merely a few lines of code, which should be rather straightforward to rectify.

1 similar comment
@unJASON
Copy link
Copy Markdown
Contributor Author

unJASON commented Feb 2, 2026

I'm truly sorry, but I really don't have an ample amount of time at the moment. You see, it seems to me that the situation is quite evident. In fact, the modifications required are merely a few lines of code, which should be rather straightforward to rectify.

@crossoverJie
Copy link
Copy Markdown
Member

I've added the relevant test cases.

@RobertIndie RobertIndie changed the title [Issue 1454][consumer] fix panic when messages size is 0 fix(consumer): fix panic when messages size is 0 Mar 20, 2026
@RobertIndie RobertIndie merged commit 15bd915 into apache:master Mar 20, 2026
7 checks passed
@AssKicker0214
Copy link
Copy Markdown

that's really helpful @unJASON

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.

[BUG] consumer panic if queueCh receive a message with size 0

5 participants