apache / apache/bookkeeper

[Bug] NPE throwed when recovering ledger: Cannot read field "distributionSchedule" because "this.lh" is null

Open
#3,618 0 comments 1 reaction 0 assignees View on GitHub
type/bug
Dominant language
Java
Stars
2k
Forks
976
Avg merge
6d 15h
Merged PRs (30d)
7

Description

**BUG REPORT**
NPE throwed when recovering ledger: Cannot read field "distributionSchedule" because "this.lh" is null
***Describe the bug***

A clear and concise description of what the bug is.
During LedgerRecovery, the safeRun method of AddPendingOp will be executed. When handling failed bookies, bk client will try to replace failed bookies with healthy ones. However, if a NotEnoughBookieException occurred when replacing bookies , the corresponding AddPendingOp instance will be recycled. Then bad things happened as the following logic includes field call on null object.
image

***To Reproduce***

Steps to reproduce the behavior:
The reproduce details can be seen in PendingAddOpTest#testReadOnlyLedgerHandleWithNotEnoughBookiesExceptionDuringRecoveryAdd
1. Create a ReadOnlyLedgerHandle instance and a PendingAddOp instance
2. Make sure NotEnoughBookiesException throwed during replace bookie process
3. Execute the safeRun method of the PendingAddOp instance

***Expected behavior***
NPE throwed and the error log is as followed, just the same as the issue title desrcibes

> java.lang.NullPointerException: Cannot read field "distributionSchedule" because "this.lh" is null

***Screenshots***
image

If applicable, add screenshots to help explain your problem.

***Additional context***

Add any other context about the problem here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.