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

fix: deregister failure detector in region migration #4293

Merged
merged 3 commits into from
Jul 7, 2024

Conversation

WenyXu
Copy link
Member

@WenyXu WenyXu commented Jul 5, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your

The original failure detectors of failed region was removed once the procedure was triggered. However, the from_peer may still send the heartbeats contains the failed region. We need to remove it manually to reduce false positive rate of failure detection.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.

Summary by CodeRabbit

  • New Features

    • Introduced functionalities to register and deregister failure detectors for regions.
  • Bug Fixes

    • Improved handling of region failures by adjusting the order of operations in the update process.

Copy link
Contributor

coderabbitai bot commented Jul 5, 2024

Walkthrough

The updates enhance the handling of failure detectors for region migrations. Specifically, the register_failure_detectors method now accommodates failed regions, and a new deregister_failure_detectors method has been introduced. Changes include modifying parameters for these methods based on to_peer instead of from_peer. Additionally, the control flow in upgrade_candidate_region.rs has been adjusted by adding an awaited call to deregister_failure_detectors() before opening the region guard.

Changes

Files & Changes Summary
src/meta-srv/src/procedure/region_migration.rs Modified register_failure_detectors and added deregister_failure_detectors to handle failure detectors.
src/.../region_migration/update_metadata/upgrade_candidate_region.rs Added deregister_failure_detectors() call before opening the region guard, affecting control flow.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Context
    participant RegionMigration
    participant FailureDetector
    participant MetadataUpdater

    Context ->> RegionMigration: startMigration()
    RegionMigration ->> Context: registerFailureDetectors(to_peer)
    Context ->> FailureDetector: register(to_peer)

    Note over RegionMigration, Context: Migration process...

    RegionMigration ->> MetadataUpdater: updateMetadata()
    MetadataUpdater ->> Context: deregisterFailureDetectors()
    Context ->> FailureDetector: deregister(to_peer)
    MetadataUpdater ->> RegionMigration: openRegionGuard()

    Note over RegionMigration: Continue migration...
Loading

Poem

In the forest deep and vast,
Migration tasks are done at last.
Failure detectors, registered with care,
Deregistered now, no burdens to bear.
Control flows adjusted, all’s in sync,
Our regions migrate, smooth as a blink.
The code now hums, like a summer's tune,
A dance of bytes, under the moon. 🌕✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@WenyXu WenyXu requested a review from fengjiachun July 5, 2024 06:45
@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Jul 5, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 849e0b9 and 06654e9.

Files selected for processing (1)
  • src/meta-srv/src/procedure/region_migration.rs (1 hunks)
Additional comments not posted (2)
src/meta-srv/src/procedure/region_migration.rs (2)

245-251: LGTM! The changes align with the context.

The use of to_peer for the datanode_id correctly aligns with the registration of failure detectors for the destination peer during region migration.


259-271: LGTM! The new function correctly handles deregistration.

The introduction of deregister_failure_detectors and the use of from_peer for the datanode_id correctly addresses the issue of false positives in failure detection.

@WenyXu WenyXu force-pushed the fix/deregister-failure-detector branch from 06654e9 to 92b0fc5 Compare July 5, 2024 06:51
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 06654e9 and 92b0fc5.

Files selected for processing (2)
  • src/meta-srv/src/procedure/region_migration.rs (2 hunks)
  • src/meta-srv/src/procedure/region_migration/update_metadata/upgrade_candidate_region.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/meta-srv/src/procedure/region_migration.rs
Additional comments not posted (1)
src/meta-srv/src/procedure/region_migration/update_metadata/upgrade_candidate_region.rs (1)

179-180: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to upgrade_candidate_region correctly handle the new call to deregister_failure_detectors.


</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Copy link

codecov bot commented Jul 5, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 84.88%. Comparing base (b1219fa) to head (9ec0344).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4293      +/-   ##
==========================================
- Coverage   85.25%   84.88%   -0.37%     
==========================================
  Files        1058     1060       +2     
  Lines      186971   187543     +572     
==========================================
- Hits       159404   159200     -204     
- Misses      27567    28343     +776     

Copy link
Collaborator

@fengjiachun fengjiachun left a comment

Choose a reason for hiding this comment

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

LGTM

@WenyXu WenyXu enabled auto-merge July 7, 2024 06:43
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 92b0fc5 and 9ec0344.

Files selected for processing (1)
  • src/meta-srv/src/procedure/region_migration/update_metadata/upgrade_candidate_region.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/meta-srv/src/procedure/region_migration/update_metadata/upgrade_candidate_region.rs

@WenyXu WenyXu added this pull request to the merge queue Jul 7, 2024
Merged via the queue into GreptimeTeam:main with commit 58f991b Jul 7, 2024
54 checks passed
@WenyXu WenyXu deleted the fix/deregister-failure-detector branch July 7, 2024 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants