Skip to content

[store]: refactor: upgrade raft to 0.6.2-alpha.10#1526

Merged
databend-bot merged 2 commits into
databendlabs:masterfrom
drmingdrmer:trac
Aug 20, 2021
Merged

[store]: refactor: upgrade raft to 0.6.2-alpha.10#1526
databend-bot merged 2 commits into
databendlabs:masterfrom
drmingdrmer:trac

Conversation

@drmingdrmer

Copy link
Copy Markdown
Member

I hereby agree to the terms of the CLA available at: https://datafuse.rs/policies/cla/

Summary

[store]: refactor: upgrade raft to 0.6.2-alpha.10

change-membership should be log driven but not channel driven

databendlabs/openraft@v0.6.2-alpha.9...datafuse-extras:v0.6.2-alpha.10

A membership change involves two steps: the joint config phase and the
final config phase.
Each phase has a corresponding log invovled.

Previously the raft setup several channel to organize this workflow,
which makes the logic hard to understand and introduces complexity when
restarting or leadership transfered: it needs to re-establish the channels and tasks.

According to the gist of raft, all workflow should be log driven.
Thus the new approach:

  • Write two log(the joint and the final) at once it recevies a
    change-membership request.
  • All following job is done according to just what log is committed.

This simplifies the workflow and makes it more reliable and intuitive to
understand.

Related changes:

  • When change_membership is called, append 2 logs at once.

  • Introduce universal response channel type to send back a message when
    some internal task is done: ResponseTx, and a universal response
    error type: ResponseError.

  • Internal response channel is now an Option<ResponseTx>, since the
    first step of membership change does not need to respond to the
    caller.

  • When a new leaser established, if the last log is a joint config
    log, append a final config log to let the partial change-membership be
    able to complete.

    And the test is added.

  • Removed membership related channels.

[store] refactor: add per-case logging

Introduce common_tracing::init_tracing() to create a logger that will be
released when being dropped.

Every test need to hold a guard to ensure the log subscriber
working.

Elaborate some tracing span arguments.

Changelog

  • Improvement

Related Issues

Introduce common_tracing::init_tracing() to create a logger that will be
released when being dropped.

Every test need to hold a `guard` to ensure the log subscriber
working.

Elaborate some tracing span arguments.
change-membership should be log driven but not channel driven

databendlabs/openraft@v0.6.2-alpha.9...datafuse-extras:v0.6.2-alpha.10

A membership change involves two steps: the joint config phase and the
final config phase.
Each phase has a corresponding log invovled.

Previously the raft setup several channel to organize this workflow,
which makes the logic hard to understand and introduces complexity when
restarting or leadership transfered: it needs to re-establish the channels and tasks.

According to the gist of raft, all workflow should be log driven.
Thus the new approach:
- Write two log(the joint and the final) at once it recevies a
  change-membership request.
- All following job is done according to just what log is committed.

This simplifies the workflow and makes it more reliable and intuitive to
understand.

Related changes:

- When `change_membership` is called, append 2 logs at once.

- Introduce universal response channel type to send back a message when
  some internal task is done: `ResponseTx`, and a universal response
  error type: `ResponseError`.

- Internal response channel is now an `Option<ResponseTx>`, since the
  first step of membership change does not need to respond to the
  caller.

- When a new leaser established, if the **last** log is a joint config
  log, append a final config log to let the partial change-membership be
  able to complete.

  And the test is added.

- Removed membership related channels.
@drmingdrmer drmingdrmer added this to the v0.5 milestone Aug 19, 2021
@databend-bot

Copy link
Copy Markdown
Member

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

3 similar comments
@databend-bot

Copy link
Copy Markdown
Member

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@databend-bot

Copy link
Copy Markdown
Member

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@databend-bot

Copy link
Copy Markdown
Member

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@drmingdrmer
drmingdrmer marked this pull request as ready for review August 19, 2021 18:10
@drmingdrmer
drmingdrmer marked this pull request as draft August 19, 2021 18:26
@drmingdrmer
drmingdrmer marked this pull request as ready for review August 19, 2021 18:45

@bohutang bohutang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cool
Thank you @drmingdrmer

@databend-bot

Copy link
Copy Markdown
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
databend-bot merged commit 08ca3de into databendlabs:master Aug 20, 2021
@drmingdrmer
drmingdrmer deleted the trac branch August 20, 2021 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants