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][broker] Fix NPE during active consumer is disconnected #24008

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

rdhabalia
Copy link
Contributor

@rdhabalia rdhabalia commented Feb 20, 2025

Motivation

Currently broker faces below NPE when active consumer disconnects and no other consumers are connected on fail-over subscription

07:11:28.357 [broker-topic-workers-OrderedExecutor-3-0] ERROR org.apache.bookkeeper.common.util.SingleThreadExecutor - Error while running task: Cannot invoke "org.apache.pulsar.broker.service
.Consumer.consumerName()" because "activeConsumer" is null
java.lang.NullPointerException: Cannot invoke "org.apache.pulsar.broker.service.Consumer.consumerName()" because "activeConsumer" is null
        at org.apache.pulsar.broker.service.persistent.PersistentDispatcherSingleActiveConsumer.readMoreEntries(PersistentDispatcherSingleActiveConsumer.java:353) ~[pulsar-broker-.jar:]
        at org.apache.pulsar.broker.service.persistent.PersistentDispatcherSingleActiveConsumer.lambda$dispatchEntriesToConsumer$2(PersistentDispatcherSingleActiveConsumer.java:242) ~[pulsar-broker-.jar:]
        at org.apache.bookkeeper.common.util.SingleThreadExecutor.safeRunTask(SingleThreadExecutor.java:137) [bookkeeper-common-4.17.1.jar:4.17.1]
        at org.apache.bookkeeper.common.util.SingleThreadExecutor.run(SingleThreadExecutor.java:113) [bookkeeper-common-4.17.1.jar:4.17.1]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.111.Final.jar:4.1.111.Final]
        at java.lang.Thread.run(Thread.java:840) [?:?]
        

Modifications

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 the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@rdhabalia rdhabalia added area/broker doc-not-needed Your PR changes do not impact docs ready-to-test labels Feb 20, 2025
@rdhabalia rdhabalia self-assigned this Feb 20, 2025
@codecov-commenter
Copy link

codecov-commenter commented Feb 20, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.19%. Comparing base (bbc6224) to head (f5d90ef).
Report is 928 commits behind head on master.

Files with missing lines Patch % Lines
...tent/PersistentDispatcherSingleActiveConsumer.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24008      +/-   ##
============================================
+ Coverage     73.57%   74.19%   +0.61%     
+ Complexity    32624    32267     -357     
============================================
  Files          1877     1854      -23     
  Lines        139502   143880    +4378     
  Branches      15299    16353    +1054     
============================================
+ Hits         102638   106746    +4108     
+ Misses        28908    28744     -164     
- Partials       7956     8390     +434     
Flag Coverage Δ
inttests 26.75% <0.00%> (+2.16%) ⬆️
systests 23.26% <0.00%> (-1.07%) ⬇️
unittests 73.70% <50.00%> (+0.85%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...tent/PersistentDispatcherSingleActiveConsumer.java 67.75% <50.00%> (-1.18%) ⬇️

... and 1043 files with indirect coverage changes

@nodece nodece merged commit dbc09e1 into apache:master Feb 20, 2025
56 of 58 checks passed
@rdhabalia rdhabalia deleted the npe_active branch February 20, 2025 19:21
@lhotari
Copy link
Member

lhotari commented Feb 21, 2025

Not cherry-picking to branch-3.0 since it doesn't contain #22285 which introduced the NPE.

lhotari pushed a commit that referenced this pull request Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants