-
Notifications
You must be signed in to change notification settings - Fork 313
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: add build info for flow heartbeat task #4228
feat: add build info for flow heartbeat task #4228
Conversation
WalkthroughThe provided changes streamline logging, refactor code for better readability and efficiency, and make structural modifications in the Datanode and HeartbeatTask implementations across various files. Additionally, a workspace entry is added in the Cargo.toml, and asynchronous behavior in region disk usage is removed for performance enhancements. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Datanode
participant HeartbeatTask
User->>Datanode: Initiates closing of heartbeat_task
Datanode->>HeartbeatTask: Sends close request without awaiting
Note right of Datanode: Improves performance
Note over HeartbeatTask: Start time tracking is added
HeartbeatTask->>HeartbeatTask: Initialize start_time_ms
Note over HeartbeatTask: Changed build_node_info to return Optional<NodeInfo>
HeartbeatTask->>HeartbeatTask: create_heartbeat_request(message, peer, start_time_ms)
Note right of HeartbeatTask: Handles new parameters and error handling
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range and nitpick comments (1)
src/datanode/src/heartbeat.rs (1)
Line range hint
248-329
: Refactor suggestion forload_region_stats
method.The method has been refactored to use a more functional style with
map
, which improves readability and efficiency. However, consider handling the case whereregion_disk_usage
might returnNone
more gracefully.- approximate_bytes: region_server.region_disk_usage(stat.region_id).unwrap_or(0), + approximate_bytes: region_server.region_disk_usage(stat.region_id).unwrap_or_default(),This change ensures that if
region_disk_usage
returnsNone
, it defaults to0
without causing a panic.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (6)
- src/datanode/src/datanode.rs (1 hunks)
- src/datanode/src/heartbeat.rs (3 hunks)
- src/datanode/src/region_server.rs (1 hunks)
- src/flow/Cargo.toml (1 hunks)
- src/flow/src/heartbeat.rs (6 hunks)
- src/frontend/src/heartbeat.rs (2 hunks)
Files skipped from review due to trivial changes (2)
- src/datanode/src/datanode.rs
- src/flow/Cargo.toml
Additional comments not posted (7)
src/frontend/src/heartbeat.rs (2)
135-142
: Enhancement inbuild_node_info
method.The method now returns
Option<NodeInfo>
, which allows for better error handling by calling methods. The inclusion ofstart_time_ms
is aligned with the PR's goal to add build information. Ensure that all callers handle theNone
case appropriately.
166-174
: Usage ofcreate_heartbeat_request
in heartbeat report loop.The method is correctly used to create heartbeat requests based on conditions. This dynamic creation based on message availability is a good use of Rust's pattern matching and option handling. Ensure that the
None
case for the sender being dropped is adequately handled in the system's overall error management strategy.src/flow/src/heartbeat.rs (2)
111-117
: Enhancement inbuild_node_info
method.This method now returns
Option<NodeInfo>
, which allows for better error handling. The inclusion ofstart_time_ms
aligns with the PR's objectives. Ensure that all callers handle theNone
case appropriately.
142-149
: Usage ofcreate_heartbeat_request
in heartbeat report loop.The method is used correctly to create heartbeat requests based on message availability. This dynamic creation is a good application of Rust's pattern matching and option handling. Ensure that the
None
case for the sender being dropped is adequately handled.src/datanode/src/heartbeat.rs (2)
161-161
: Added tracing inhandle_response
method.The addition of a trace log before handling a heartbeat response is a good practice for debugging and monitoring. Ensure that the logging level and message are appropriate for the operation's importance and frequency.
332-332
: Proper handling inclose
method.The method now properly checks if the heartbeat task is already closed before proceeding. This is a good practice to prevent errors from multiple closures. Ensure that any resources are properly cleaned up after closure.
src/datanode/src/region_server.rs (1)
293-293
: Updatedregion_disk_usage
method.The method has been updated to remove its asynchronous nature, which simplifies the interface and potentially improves performance by reducing overhead. Ensure that all callers have been updated to handle this synchronous method appropriately.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4228 +/- ##
==========================================
- Coverage 84.89% 84.57% -0.32%
==========================================
Files 1040 1045 +5
Lines 183506 184274 +768
==========================================
+ Hits 155789 155852 +63
- Misses 27717 28422 +705 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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?
Checklist
Summary by CodeRabbit
New Features
Improvements
Refactor