Describe the bug
When adding new entry, bookie failure and zookeeper disconnection may cause inconsistency between LedgerInfo.getEntries and LedgerMetadata.getLastEntryId. This will introduce duplicated entry.
To Reproduce
- Adding
entry-a to ledger1.
- Succeed to persist on disk, but failed to response due to, say, machine crash.
- Zookeeper disconnected, thus fail to write metadata and closing ledger.
- Report
ledgerClosed to ManagedLedger.
- Zookeeper reconnected.
- Roll to
ledger2, entry-a added success.
ManagedLedger does not count entry-a in LedgerInfo.getEntries, but entry-a does count as LedgerMetadata.getLastEntryId and LedgerHandle.getLastAddConfirmed after recovery.
ManagedCursor does not use LedgerInfo.getEntries to restrict its reading.
LedgerOffloader does not use LedgerInfo.getEntries either.
I have add test case to reproduce this: kezhuw@bc0de5e.
Strictly speaking, I think OpAddEntry.handleAddTimeoutFailure has this issue too.
Describe the bug
When adding new entry, bookie failure and zookeeper disconnection may cause inconsistency between
LedgerInfo.getEntriesandLedgerMetadata.getLastEntryId. This will introduce duplicated entry.To Reproduce
entry-atoledger1.ledgerClosedtoManagedLedger.ledger2,entry-aadded success.ManagedLedgerdoes not countentry-ainLedgerInfo.getEntries, butentry-adoes count asLedgerMetadata.getLastEntryIdandLedgerHandle.getLastAddConfirmedafter recovery.ManagedCursordoes not useLedgerInfo.getEntriesto restrict its reading.LedgerOffloaderdoes not useLedgerInfo.getEntrieseither.I have add test case to reproduce this: kezhuw@bc0de5e.
Strictly speaking, I think
OpAddEntry.handleAddTimeoutFailurehas this issue too.