Skip to content

Add fencing to recovery reads to avoid data loss issue - #2616

Merged
eolivelli merged 3 commits into
apache:masterfrom
Vanlightly:fix-fencing
Mar 12, 2021
Merged

eolivelli merged 3 commits into
apache:masterfrom
Vanlightly:fix-fencing

Conversation

@Vanlightly

Copy link
Copy Markdown
Contributor

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

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dlg99 please take a look, probably it is worth to pick this fix for 4.13.0

@eolivelli

Copy link
Copy Markdown
Contributor

@Vanlightly PR validation failed. PTAL

Thank you very much for sharing your findings and also provide a fix

@dlg99 dlg99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vanlightly it is an awesome catch and the fix lgtm.
One note about the test: often reliance on Thread.sleep() leads to test flakiness.
Can I ask you to try to remove these and replace with wait for completion of specific events?

@dlg99

dlg99 commented Feb 22, 2021

Copy link
Copy Markdown
Contributor

Another note: NoSuchLedger/NoSuchEntry have special handling in PendingReadLacOp/RoundRobinDistributionSchedule, see #2612
Is it possible to repro case when at lac N write N+1 is lost?

@Vanlightly

Copy link
Copy Markdown
Contributor Author

Yes of course. I'll take a look at both suggestions.

Also seeded the ledger such that the LAC of the bookies is 0 rather
than -1. It doesn't make a huge difference but covers the more
likely scenario of a ledger with more than one acknowledged entry.
@Vanlightly

Copy link
Copy Markdown
Contributor Author

@dlg99 I've replaced the Thread.sleep with CompletableFutures to ensure the right sequence is followed in a non-flaky way.

Regarding the issue #2612, I've left a comment there. Basically the protocol is not designed to handle arbitrary failures of that kind and data loss can result. In terms of this particular issue, which is not an arbitrary failure scenario, I think the current test is probably enough.

@dlg99

dlg99 commented Mar 1, 2021

Copy link
Copy Markdown
Contributor

@Vanlightly Thank you! The changes lgtm.

@eolivelli eolivelli added this to the 4.14.0 milestone Mar 12, 2021
@eolivelli
eolivelli merged commit 017307b into apache:master Mar 12, 2021
eolivelli pushed a commit that referenced this pull request Mar 12, 2021
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](#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 <[email protected]>, Andrey Yegorov <[email protected]>

This closes #2616 from Vanlightly/fix-fencing

(cherry picked from commit 017307b)
Signed-off-by: Enrico Olivelli <[email protected]>
@eolivelli

Copy link
Copy Markdown
Contributor

pushed to master branch and to branch-4.12.

thank you very much @Vanlightly

I believe you are now unblocked in sending the next PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants