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

feat: flow recreate on reboot #4509

Merged
merged 4 commits into from
Aug 5, 2024
Merged

Conversation

discord9
Copy link
Contributor

@discord9 discord9 commented Aug 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 intention?

recreate flow on flownode on reboot

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

    • Enhanced flow management by integrating a new FlowMetadataManager into the StartCommand functionality.
    • Introduced a new asynchronous method, recover_flows, in FlownodeBuilder to handle flow recovery tasks.
    • Updated SQL scripts to support new execution parameters, improving SQL operation configurations.
  • Bug Fixes

    • Improved error handling by adding a new ListFlows variant to the error reporting system.
  • Chores

    • Adjusted several builder implementations to utilize the new flow metadata manager for better management of flow operations.

@discord9 discord9 requested review from zhongzc, waynexia and a team as code owners August 5, 2024 08:53
Copy link
Contributor

coderabbitai bot commented Aug 5, 2024

Walkthrough

The updates enhance flow management across multiple components, integrating a new FlowMetadataManager into the command implementations and the FlownodeBuilder. This refactor improves data handling and error reporting, facilitating clearer and more maintainable flow-related operations.

Changes

Files Change Summary
src/cmd/src/flownode.rs, src/cmd/src/standalone.rs Introduced FlowMetadataManager to StartCommand, modifying instantiation and usage for improved data flow.
src/flow/src/error.rs Added ListFlows variant to Error enum for better error handling related to flow listing.
src/flow/src/server.rs Updated FlownodeBuilder to include a flow_metadata_manager field and added a new method, recover_flows, for flow recovery.
tests-integration/src/standalone.rs Modified GreptimeDbStandaloneBuilder to include flow_metadata_manager for enhanced functionality.
tests/cases/standalone/common/flow/*.sql Added SQL comments and statements to enhance functionality related to database operations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant StartCommand
    participant FlowMetadataManager
    participant FlownodeBuilder

    User->>StartCommand: Initiate Flow
    StartCommand->>FlowMetadataManager: Create Instance
    StartCommand->>FlownodeBuilder: Pass FlowMetadataManager
    FlownodeBuilder->>FlowMetadataManager: Access Metadata
    FlownodeBuilder->>User: Execute Flow Operations
Loading

🐰 In a garden lush and bright,
With flows that dance in morning light,
New managers join the fray,
To guide our paths both night and day.
Let's hop and cheer, for change is here! 🌼✨


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 Configuration 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.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Aug 5, 2024
src/flow/src/server.rs Outdated Show resolved Hide resolved
src/flow/src/server.rs Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 5, 2024

Codecov Report

Attention: Patch coverage is 39.72603% with 44 lines in your changes missing coverage. Please review.

Project coverage is 84.73%. Comparing base (3b701d8) to head (7f6fd24).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4509      +/-   ##
==========================================
- Coverage   84.97%   84.73%   -0.24%     
==========================================
  Files        1081     1084       +3     
  Lines      193362   193935     +573     
==========================================
+ Hits       164314   164340      +26     
- Misses      29048    29595     +547     

src/flow/src/server.rs Outdated Show resolved Hide resolved
@killme2008
Copy link
Contributor

We must be focused on such basic functions. Keep pushing and make the flow better.

@discord9
Copy link
Contributor Author

discord9 commented Aug 5, 2024

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Aug 5, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8037800 and 7f6fd24.

Files selected for processing (7)
  • src/cmd/src/flownode.rs (2 hunks)
  • src/cmd/src/standalone.rs (2 hunks)
  • src/flow/src/error.rs (2 hunks)
  • src/flow/src/server.rs (7 hunks)
  • tests-integration/src/standalone.rs (1 hunks)
  • tests/cases/standalone/common/flow/flow_basic.result (1 hunks)
  • tests/cases/standalone/common/flow/flow_basic.sql (1 hunks)
Additional comments not posted (16)
tests/cases/standalone/common/flow/flow_basic.sql (2)

17-17: Verify the purpose and placement of the SQL comment.

The comment -- SQLNESS ARG restart=true indicates a new argument for the SQL execution environment. Ensure that it is correctly placed and does not interfere with the SQL statements.


18-20: Verify the correctness and consistency of the data entries.

The INSERT statement adds new data entries to the numbers_input_basic table. Ensure that the data entries are correct and consistent with the table schema.

tests/cases/standalone/common/flow/flow_basic.result (2)

27-27: Verify the purpose and placement of the SQL comment.

The comment -- SQLNESS ARG restart=true indicates a new argument for the SQL execution environment. Ensure that it is correctly placed and does not interfere with the expected results.


28-28: Verify the correctness and consistency of the expected results.

The expected results include the affected rows and the results of the flush_flow and SELECT statements. Ensure that the expected results are correct and consistent with the SQL statements in flow_basic.sql.

src/flow/src/error.rs (2)

86-92: Verify the correctness and integration of the new error variant.

The new error variant ListFlows includes three fields: id, source, and location. Ensure that it is correctly defined and integrated into the Error enum.


225-226: Verify the correctness and consistency of the modifications.

The modifications include the addition of the ListFlows variant to the match arm that returns a StatusCode::TableNotFound. Ensure that the modifications are correctly implemented and consistent with the error handling logic.

tests-integration/src/standalone.rs (1)

159-159: Ensure flow_metadata_manager is correctly integrated.

The addition of flow_metadata_manager.clone() to the FlownodeBuilder constructor is consistent with the PR objectives. Ensure that this parameter is correctly utilized within the builder to manage flow metadata.

src/cmd/src/flownode.rs (3)

27-27: Import statement for FlowMetadataManager.

The import statement for FlowMetadataManager is correctly added.


300-300: Initialization of FlowMetadataManager.

The initialization of FlowMetadataManager using cached_meta_backend is consistent with the intended functionality. Ensure that cached_meta_backend is correctly configured and passed to the manager.


306-306: Passing flow_metadata_manager to FlownodeBuilder.

The flow_metadata_manager is correctly passed as a parameter to the FlownodeBuilder. This aligns with the PR objectives of enhancing flow management.

src/flow/src/server.rs (5)

32-32: Import statement for FlowMetadataManagerRef.

The import statement for FlowMetadataManagerRef is correctly added.


245-245: Addition of flow_metadata_manager field to FlownodeBuilder.

The flow_metadata_manager field is correctly added to the FlownodeBuilder struct. This enhances the builder's ability to manage flow metadata.


256-256: Updating the constructor to initialize flow_metadata_manager.

The constructor for FlownodeBuilder is correctly updated to initialize the flow_metadata_manager field.


292-294: Error handling in flow recovery.

The error handling for flow recovery is correctly implemented using the Snafu library. This ensures robust management of potential failures.


309-386: Implementation of recover_flows method.

The recover_flows method is well-implemented, providing a robust approach to recovering flow tasks based on the node's operational mode. Consider parallelizing the recovery process in the future for improved performance.

src/cmd/src/standalone.rs (1)

479-485: LGTM! Verify the impact of the moved instantiation.

The code changes are approved.

However, ensure that the moved instantiation of flow_metadata_manager does not introduce any issues or dependencies in the codebase.

Verification successful

No issues found with the moved instantiation of flow_metadata_manager.

The moved instantiation of flow_metadata_manager does not introduce any issues or dependencies in the codebase. The change improves code clarity and maintainability.

  • The flow_metadata_manager is instantiated and used consistently across various files without any dependency issues.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the moved instantiation of `flow_metadata_manager`.

# Test: Search for the `flow_metadata_manager` usage. Expect: No issues or dependencies introduced.
rg --type rust -A 5 $'flow_metadata_manager'

Length of output: 30599

@discord9 discord9 added this pull request to the merge queue Aug 5, 2024
Merged via the queue into GreptimeTeam:main with commit e6cc4df Aug 5, 2024
34 checks passed
@discord9 discord9 deleted the flow_reboot branch August 5, 2024 14:16
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.

4 participants