-
Notifications
You must be signed in to change notification settings - Fork 110
fix: clean up worker threads in the event of an error #2783
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: 07-18-fix_make_query_as_macros_retry
Are you sure you want to change the base?
fix: clean up worker threads in the event of an error #2783
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Claude finished @MasterPtato's task —— View job PR Review: Clean up worker threads in the event of an errorReview Checklist
Changes SummaryThis PR addresses proper cleanup of background tasks when the worker encounters errors. The main changes are:
✅ Positive AspectsExcellent Bug Fix: This addresses a real resource leak issue where background GC and metrics tasks would continue running after the main worker loop exits due to errors. Consistent Error Handling: The fix applies the same cleanup pattern across all error exit paths ( Clear Code Organization: Reordering the Good Documentation: The added comment at 🔍 Code Quality AnalysisRust Best Practices: ✅
Error Handling: ✅
🐛 Potential IssuesMinor: Duplication: The cleanup code ( impl Worker {
fn abort_background_tasks(&self, gc_handle: &JoinHandle<()>, metrics_handle: &JoinHandle<()>) {
gc_handle.abort();
metrics_handle.abort();
}
} Edge Case: If 🚀 Performance ConsiderationsResource Cleanup: ✅ Improves performance by preventing background tasks from continuing unnecessarily after errors. No Performance Regression: The changes add minimal overhead (two function calls) only in error paths. 🔒 Security AssessmentNo Security Issues: This is defensive cleanup code that improves resource management. No security implications. 🧪 Test Coverage RecommendationsConsider adding tests for:
Example test structure: #[tokio::test]
async fn test_background_task_cleanup_on_tick_error() {
// Setup worker with mocked dependencies that will cause tick() to fail
// Verify gc_handle.is_finished() and metrics_handle.is_finished() return true
} 📋 Overall AssessmentStrong Approve ✅ This is a well-implemented bug fix that addresses a real resource management issue. The changes are minimal, focused, and follow Rust best practices. The only suggestion is the minor code deduplication opportunity mentioned above. Files Changed: |
2d84554
to
f64697c
Compare
d29d739
to
17d427c
Compare
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
||
tick_interval.reset(); | ||
}, | ||
|
||
res = &mut gc_handle => { | ||
tracing::error!(?res, "metrics task unexpectedly stopped"); |
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.
The error message in this line is incorrect - it's logging "metrics task unexpectedly stopped" when handling the result from gc_handle
. This should be updated to "gc task unexpectedly stopped" to accurately reflect which task failed.
tracing::error!(?res, "metrics task unexpectedly stopped"); | |
tracing::error!(?res, "gc task unexpectedly stopped"); |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
Deploying rivet-hub with
|
Latest commit: |
17d427c
|
Status: | ✅ Deploy successful! |
Preview URL: | https://f0ac695a.rivet-hub-7jb.pages.dev |
Branch Preview URL: | https://07-21-fix-clean-up-worker-th.rivet-hub-7jb.pages.dev |
Changes