Add fencing to recovery reads to avoid data loss issue

Descriptions of the changes in this PR:

### Motivation

Adding the fencing flag to recovery reads avoids a data loss scenario as described in [issue 2614](

### Changes

Added the fencing flag to recovery reads. Refactored some mocking unit test code to introduce fencing and allow two writers to share the same bookie state. Added a new unit to verify the fix. You can recreate the initial problem by removing the fencing flag from recovery reads and running the new unit test.

Master Issue: #2614

Reviewers: Enrico Olivelli <>, Andrey Yegorov <>

This closes #2616 from Vanlightly/fix-fencing

(cherry picked from commit 017307bc67431a7616861ad09927c4e3327633d1)
Signed-off-by: Enrico Olivelli <>
6 files changed
tree: 32e9dd055e1b8280f59c75da0c6b499e1879c55e
  1. .github/
  2. .gitignore
  3. .test-infra/
  4. Jenkinsfile
  8. bin/
  9. bookkeeper-benchmark/
  10. bookkeeper-common-allocator/
  11. bookkeeper-common/
  12. bookkeeper-dist/
  13. bookkeeper-http/
  14. bookkeeper-proto/
  15. bookkeeper-server/
  16. bookkeeper-stats-providers/
  17. bookkeeper-stats/
  18. buildtools/
  19. circe-checksum/
  20. conf/
  21. cpu-affinity/
  22. deploy/
  23. dev/
  24. docker/
  25. metadata-drivers/
  26. microbenchmarks/
  27. pom.xml
  28. shaded/
  29. site/
  30. site2/
  31. stats/
  32. stream/
  33. tests/
  34. tools/

Build Status Build Status Coverage Status Maven Central

Apache BookKeeper

Apache BookKeeper is a scalable, fault tolerant and low latency storage service optimized for append-only workloads.

It is suitable for being used in following scenarios:

  • WAL (Write-Ahead-Logging), e.g. HDFS NameNode.
  • Message Store, e.g. Apache Pulsar.
  • Offset/Cursor Store, e.g. Apache Pulsar.
  • Object/Blob Store, e.g. storing state machine snapshots.

Get Started

  • Concepts: Start with the basic concepts of Apache BookKeeper. This will help you to fully understand the other parts of the documentation.
  • Getting Started to setup BookKeeper to write logs.



You can also read Turning Ledgers into Logs to learn how to turn ledgers into continuous log streams. If you are looking for a high level log stream API, you can checkout DistributedLog.



Get In Touch

Report a Bug

For filing bugs, suggesting improvements, or requesting new features, help us out by opening a Github issue or opening an Apache jira.

Need Help?

Subscribe or mail the list - Ask questions, find answers, and also help other users.

Subscribe or mail the list - Join development discussions, propose new ideas and connect with contributors.

Join us on Slack - This is the most immediate way to connect with Apache BookKeeper committers and contributors.


We feel that a welcoming open community is important and welcome contributions.

Contributing Code

  1. See Developer Setup to get your local environment setup.

  2. Take a look at our open issues: JIRA Issues Github Issues.

  3. Review our coding style and follow our pull requests to learn about our conventions.

  4. Make your changes according to our contribution guide.

Improving Website and Documentation

  1. See Building the website and documentation on how to build the website and documentation.