Skip to content

Entry duplicated in pulsar when bookie failed and zookeeper disconnected #7490

Description

@kezhuw

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

  1. Adding entry-a to ledger1.
  2. Succeed to persist on disk, but failed to response due to, say, machine crash.
  3. Zookeeper disconnected, thus fail to write metadata and closing ledger.
  4. Report ledgerClosed to ManagedLedger.
  5. Zookeeper reconnected.
  6. Roll to ledger2, entry-a added success.
  7. ManagedLedger does not count entry-a in LedgerInfo.getEntries, but entry-a does count as LedgerMetadata.getLastEntryId and LedgerHandle.getLastAddConfirmed after recovery.
  8. ManagedCursor does not use LedgerInfo.getEntries to restrict its reading.
  9. 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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions