[Bug] NPE throwed when recovering ledger: Cannot read field "distributionSchedule" because "this.lh" is null
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 160
Description
### Search before asking
- [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
### Version
Pulsar 2.11
### Minimal reproduce step
I don't know how to reproduce it
### What did you expect to see?
Recover ledger successfully
### What did you see instead?
9333 Oct 23 16:55:56 test_host pulsar[123890]: 2022-10-23T16:55:56,889+0800 [BookKeeperClientWorker-OrderedExecutor-1-0] WARN org.apache.pulsar.broker.service.BrokerSe
9333 rvice - Failed to create topic persistent://benchmark/ns-test/test-test-reusing-topic500-0000-partition-426
9334 Oct 23 16:55:56 test_host pulsar[123890]: org.apache.bookkeeper.mledger.ManagedLedgerException: Error while recovering ledger
9335 Oct 23 16:55:56 test_host pulsar[123890]: 2022-10-23T16:55:56,889+0800 [main-EventThread] INFO org.apache.bookkeeper.client.LedgerCreateOp - Ensemble: [10.225.50.
9335 43:3181, 10.224.145.38:3181, 10.225.105.4:3181] for ledger: 24474
9336 Oct 23 16:55:56 test_host pulsar[123890]: 2022-10-23T16:55:56,889+0800 [BookKeeperClientWorker-OrderedExecutor-26-0] ERROR org.apache.bookkeeper.common.util.SafeRu
9336 nnable - Unexpected throwable caught
9337 Oct 23 16:55:56 test_host pulsar[123890]: java.lang.NullPointerException: Cannot read field "distributionSchedule" because "this.lh" is null
9338 Oct 23 16:55:56 test_host pulsar[123890]: at org.apache.bookkeeper.client.PendingAddOp.safeRun(PendingAddOp.java:272) ~[org.apache.bookkeeper-bookkeeper-server-4.1 9338 6.1-SNAPSHOT.jar:4.16.1-SNAPSHOT]
9339 Oct 23 16:55:56 test_host pulsar[123890]: at org.apache.bookkeeper.common.util.SafeRunnable.run(SafeRunnable.java:36) ~[org.apache.bookkeeper-bookkeeper-common-4.1 9339 6.1-SNAPSHOT.jar:4.16.1-SNAPSHOT]
9340 Oct 23 16:55:56 test_host pulsar[123890]: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
9341 Oct 23 16:55:56 test_host pulsar[123890]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
9342 Oct 23 16:55:56 test_host pulsar[123890]: at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[io.netty-netty-common-4.1.77.F 9342 inal.jar:4.1.77.Final]
9343 Oct 23 16:55:56 test_host pulsar[123890]: at java.lang.Thread.run(Thread.java:833) ~[?:?]
### Anything else?
_No response_
### Are you willing to submit a PR?
- [X] I'm willing to submit a PR!
Contributor guide
Research direction
Start with org.apache.bookkeeper.client.PendingAddOp.safeRun at PendingAddOp.java:272 and trace the ledger-recovery path that reaches it with a null lh. Use the reported Pulsar 2.11 and BookKeeper 4.16.1-SNAPSHOT context to investigate the failure, since the issue provides no reproduction steps. Done means ledger recovery completes without this NullPointerException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100