Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Raft] fix some remaining problems after pre-vote merged #3415

Merged
merged 8 commits into from
Dec 9, 2021

Conversation

critical27
Copy link
Contributor

@critical27 critical27 commented Dec 6, 2021

I am reviewing current implementation, some issues are found:

  1. We didn't save the info of voting for myself when start formal election, which could lead to split brain:
    • There are ABCDE 5 replicas, and BC vote for A.
    • If A does not voted itself, another host could be the leader, for example, E could be the leader with votes from ADE.
  2. [Raft] Add prevote to make it better #3322 has missed one rollback, leader will check whether term/role changed after we get AppendLogResponse, if failed, we need to rollback, otherwise, we can't write any logs to wal since lastLogId_ != wal_->lastLogId().
  3. When we start up, if lastLogId_ < committedLogId_, only lastLogId_ is set to committedLogId_.

And some minor changes, set leader_ whenever term changed, this is a prepare for later AppendLogs refactor.

@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2021

Codecov Report

Merging #3415 (b889c81) into master (d6f83f3) will decrease coverage by 7.43%.
The diff coverage is 96.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3415      +/-   ##
==========================================
- Coverage   85.24%   77.80%   -7.44%     
==========================================
  Files        1278     1278              
  Lines      119200   119289      +89     
==========================================
- Hits       101608    92817    -8791     
- Misses      17592    26472    +8880     
Impacted Files Coverage Δ
src/common/utils/NebulaKeyUtils.h 80.68% <ø> (ø)
src/common/utils/Types.h 100.00% <ø> (ø)
src/kvstore/raftex/RaftPart.cpp 72.35% <83.33%> (+0.81%) ⬆️
src/storage/exec/GetPropNode.h 89.55% <87.50%> (-0.45%) ⬇️
src/common/memory/MemoryUtils.cpp 93.33% <100.00%> (+0.65%) ⬆️
src/common/utils/MetaKeyUtils.cpp 82.15% <100.00%> (+0.78%) ⬆️
src/common/utils/NebulaKeyUtils.cpp 94.51% <100.00%> (+0.31%) ⬆️
src/common/utils/test/MetaKeyUtilsTest.cpp 94.63% <100.00%> (+0.30%) ⬆️
src/kvstore/raftex/test/RaftCase.cpp 71.12% <100.00%> (ø)
src/kvstore/test/DiskManagerTest.cpp 99.19% <100.00%> (+0.21%) ⬆️
... and 295 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d38fc07...b889c81. Read the comment docs.

Copy link
Contributor

@panda-sheep panda-sheep left a comment

Choose a reason for hiding this comment

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

Good job!

Copy link
Contributor

@kikimo kikimo left a comment

Choose a reason for hiding this comment

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

LGTM, I'll do more test together with the following raft pr.

@critical27 critical27 merged commit 7c4e372 into vesoft-inc:master Dec 9, 2021
@critical27 critical27 deleted the raft branch December 9, 2021 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants