-
Notifications
You must be signed in to change notification settings - Fork 183
Better shutdown. #867
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
base: develop
Are you sure you want to change the base?
Better shutdown. #867
Conversation
|
Claude finished @ZanCorDX's task in 3m 28s ββ View job π PR Review: Better ShutdownThis PR improves the shutdown mechanism by replacing sleep-based waiting with SummaryThe PR introduces a two-phase shutdown mechanism:
This replaces the previous approach that used arbitrary sleeps to wait for tasks to complete. β Strengths
|
| Item | Status |
|---|---|
| Code compiles | β Appears correct |
| No security issues | β No concerns |
| Error handling | β Properly handles JoinHandle errors |
| Documentation | β Good doc comments on new structs/functions |
| Tests |
π― Overall Assessment
Approve with minor suggestions. This is a well-designed improvement to the shutdown mechanism. The two-phase approach with proper task tracking is much more robust than the previous sleep-based approach. The inline comments contain minor suggestions that can be addressed in a follow-up if desired.
| tokio::time::sleep(RUN_SUBMIT_TO_RELAYS_JOB_CANCEL_TIME).await; | ||
| task_manager.graceful_shutdown_with_timeout(Duration::from_secs(5)); | ||
| abort_token.cancelled().await; | ||
| task_manager.graceful_shutdown(); |
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.
Good design pattern: This task forwards the abort signal to the task_manager, which is cleaner than the previous approach that used a hardcoded sleep. However, ensure that task_manager.graceful_shutdown() properly signals all child tasks to complete their cleanup work before the clickhouse_shutdown_handle completes.
| let backup_handle = backup.spawn(task_executor, backup_table_name, tracing_target); | ||
|
|
||
| // Spawn a wrapper task that waits for both to complete | ||
| tokio::spawn(async move { |
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.
Good pattern: Wrapping both handles in a single task that waits for both to complete is a clean solution. This ensures the returned JoinHandle only completes when both the inserter and backup tasks have finished their cleanup.
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
|
Claude finished @ZanCorDX's task in 1m 41s ββ View job π PR Review: Better Shutdown (Re-review after sync)SummaryReviewed the latest sync which added logging of remaining tasks when graceful shutdown timeout is reached. Found one issue that should be addressed.
|
| } | ||
| } | ||
| _ = tokio::time::sleep_until(graceful_deadline) => { | ||
| warn!("Graceful shutdown timeout reached, signaling abort"); |
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.
This line appears to be redundant now that the more informative warning with task counts was added below. Consider removing it:
| warn!("Graceful shutdown timeout reached, signaling abort"); |
π Summary
Sleeps where repleaced by JoinHandles.
β I have completed the following steps:
make lintmake test