Skip to content

[fix][broker] Handle the case when getOwnedServiceUnits fails gracefully - #23119

Merged
BewareMyPower merged 3 commits into
apache:masterfrom
Demogorgon314:Demogorgon314/fix-add-namespace-bundle-ownership-listener-before-lb-start
Aug 6, 2024
Merged

[fix][broker] Handle the case when getOwnedServiceUnits fails gracefully#23119
BewareMyPower merged 3 commits into
apache:masterfrom
Demogorgon314:Demogorgon314/fix-add-namespace-bundle-ownership-listener-before-lb-start

Conversation

@Demogorgon314

Copy link
Copy Markdown
Member

Motivation

When getOwnedServiceUnits fails, the broker will fail to start, we should handle getOwnedServiceUnits fails gracefully

org.apache.pulsar.broker.PulsarServerException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot invoke "org.apache.pulsar.client.api.TableView.entrySet()" because "this.tableview" is null
    at org.apache.pulsar.broker.PulsarService.start(PulsarService.java:993)

Modifications

  • Handle getOwnedServiceUnits fails gracefully
  • Fix NPE caused by ServiceUnitStateChannel's tableview is null.

Documentation

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

@Demogorgon314 Demogorgon314 added type/bug The PR fixed a bug or issue reported a bug area/broker labels Aug 2, 2024
@Demogorgon314 Demogorgon314 self-assigned this Aug 2, 2024
@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Aug 2, 2024
@Demogorgon314
Demogorgon314 requested a review from lhotari August 2, 2024 13:23
@codecov-commenter

codecov-commenter commented Aug 5, 2024

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.46%. Comparing base (bbc6224) to head (c9e1ea3).
⚠️ Report is 1540 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23119      +/-   ##
============================================
- Coverage     73.57%   73.46%   -0.11%     
- Complexity    32624    33544     +920     
============================================
  Files          1877     1919      +42     
  Lines        139502   144125    +4623     
  Branches      15299    15748     +449     
============================================
+ Hits         102638   105886    +3248     
- Misses        28908    30118    +1210     
- Partials       7956     8121     +165     
Flag Coverage Δ
inttests 27.60% <25.00%> (+3.01%) ⬆️
systests 24.71% <25.00%> (+0.38%) ⬆️
unittests 72.54% <100.00%> (-0.31%) ⬇️

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

Files with missing lines Coverage Δ
...xtensions/channel/ServiceUnitStateChannelImpl.java 86.42% <100.00%> (+1.11%) ⬆️
...ache/pulsar/broker/namespace/NamespaceService.java 74.21% <100.00%> (+1.97%) ⬆️

... and 522 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BewareMyPower
BewareMyPower merged commit 4a44f45 into apache:master Aug 6, 2024
@Technoboy- Technoboy- added this to the 3.4.0 milestone Aug 6, 2024
lhotari pushed a commit that referenced this pull request Aug 6, 2024
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 8, 2024
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 12, 2024
lhotari pushed a commit that referenced this pull request Aug 16, 2024
Denovo1998 pushed a commit to Denovo1998/pulsar that referenced this pull request Aug 17, 2024
grssam pushed a commit to grssam/pulsar that referenced this pull request Sep 4, 2024
hanmz pushed a commit to hanmz/pulsar that referenced this pull request Feb 12, 2025
Demogorgon314 added a commit to Demogorgon314/kop that referenced this pull request Apr 15, 2026
…ative#659)

### Motivation

The follow-up PR for the new LB:
apache/pulsar#23119

The `getOwnedServiceUnits` may throw an exception after
apache/pulsar#22977 , we can ignore this
exception since the LB is not started yet.


```
pulsar-broker org.apache.pulsar.broker.PulsarServerException: java.lang.RuntimeException: java.lang.IllegalStateException: Invalid channel state:LeaderElectionServiceStarted
pulsar-broker     at org.apache.pulsar.broker.PulsarService.start(PulsarService.java:997)
pulsar-broker     at org.apache.pulsar.PulsarBrokerStarter$BrokerStarter.call(PulsarBrokerStarter.java:294)
pulsar-broker     at org.apache.pulsar.PulsarBrokerStarter$BrokerStarter.call(PulsarBrokerStarter.java:131)
pulsar-broker     at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
pulsar-broker     at picocli.CommandLine.access$1500(CommandLine.java:148)
pulsar-broker     at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
pulsar-broker     at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
pulsar-broker     at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
pulsar-broker     at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
pulsar-broker     at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
pulsar-broker     at picocli.CommandLine.execute(CommandLine.java:2170)
pulsar-broker     at org.apache.pulsar.PulsarBrokerStarter$BrokerStarter.start(PulsarBrokerStarter.java:152)
pulsar-broker     at org.apache.pulsar.PulsarBrokerStarter.main(PulsarBrokerStarter.java:386)
pulsar-broker Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: Invalid channel state:LeaderElectionServiceStarted
pulsar-broker     at org.apache.pulsar.broker.namespace.NamespaceService.getOwnedServiceUnits(NamespaceService.java:1203)
pulsar-broker     at io.streamnative.pulsar.handlers.kop.NamespaceBundleOwnershipListenerImpl.addTopicOwnershipListener(NamespaceBundleOwnershipListenerImpl.java:72)
pulsar-broker     at io.streamnative.pulsar.handlers.kop.KafkaProtocolHandler.start(KafkaProtocolHandler.java:259)
pulsar-broker     at org.apache.pulsar.broker.protocol.ProtocolHandlerWithClassLoader.start(ProtocolHandlerWithClassLoader.java:93)
pulsar-broker     at org.apache.pulsar.broker.protocol.ProtocolHandlers.lambda$start$4(ProtocolHandlers.java:153)
pulsar-broker     at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422)
pulsar-broker     at org.apache.pulsar.broker.protocol.ProtocolHandlers.start(ProtocolHandlers.java:153)
pulsar-broker     at org.apache.pulsar.broker.PulsarService.start(PulsarService.java:952)
pulsar-broker     ... 12 more
pulsar-broker Caused by: java.lang.IllegalStateException: Invalid channel state:LeaderElectionServiceStarted
pulsar-broker     at org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelImpl.getOwnershipEntrySet(ServiceUnitStateChannelImpl.java:1767)
pulsar-broker     at org.apache.pulsar.broker.loadbalance.extensions.ExtensibleLoadManagerImpl.getOwnedServiceUnitsAsync(ExtensibleLoadManagerImpl.java:217)
pulsar-broker     at org.apache.pulsar.broker.namespace.NamespaceService.getOwnedServiceUnits(NamespaceService.java:1200)
pulsar-broker     ... 19 more
pulsar-broker 2024-08-12T04:00:38,065+0000 [pulsar-service-shutdown] INFO  org.apache.pulsar.PulsarBrokerStarter - Shut down functions worker service successfully.
pulsar-broker 2024-08-12T04:00:38,074+0000 [pulsar-service-shutdown] ERROR org.apache.pulsar.PulsarBrokerStarter - Error while shutting down Pulsar service
```

### Modifications

* Handle `getOwnedServiceUnits` fails gracefully
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