-
Notifications
You must be signed in to change notification settings - Fork 253
fix: Add handle for swordfish runtime stats manager #4970
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
Conversation
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.
Greptile Summary
This PR fixes a critical runtime panic in Daft's local execution engine by refactoring how the RuntimeStatsManager
is handled throughout the execution pipeline. The panic was occurring during shutdown with the message "There should only be 1 stats manager instance by the end", indicating that multiple references to the stats manager were being created and retained, violating the singleton expectation.
The fix introduces a new RuntimeStatsManagerHandle
type that serves as a lightweight wrapper around the underlying stats manager communication channel. This handle pattern decouples the lifetime of the RuntimeStatsManager
from its users by providing a controlled interface for activating and finalizing nodes. The key changes include:
-
Introduction of
RuntimeStatsManagerHandle
: A new wrapper type that encapsulates anArc<mpsc::UnboundedSender>
for communicating with the stats manager, replacing directArc<RuntimeStatsManager>
usage throughout the codebase. -
Refactored stats manager lifecycle: The
RuntimeStatsManager
is now created directly (not wrapped in Arc) inrun.rs
, with a handle extracted immediately and passed toExecutionRuntimeContext
. This prevents the reference counting issues that were causingArc::into_inner()
to panic. -
Removed unnecessary clone operations: Multiple files had
.clone()
calls removed fromstats_manager()
method calls, since the returned handle is already designed to be cheaply cloneable. -
Graceful error handling: The handle now includes proper error handling that logs warnings instead of panicking when the stats manager channel is closed during shutdown.
This change integrates well with Daft's execution engine architecture by following common Rust patterns for resource management and cross-thread communication. The handle pattern allows the main execution thread to maintain ownership of the RuntimeStatsManager
while providing safe, controlled access to child nodes and intermediate operations.
Confidence score: 4/5
- This PR addresses a well-defined panic with a systematic solution that follows good Rust practices
- The changes are focused and consistent across multiple files, indicating thorough implementation
- The handle pattern properly decouples resource lifetime management from usage, preventing the reference counting issues
5 files reviewed, no comments
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4970 +/- ##
==========================================
+ Coverage 78.56% 79.14% +0.57%
==========================================
Files 917 917
Lines 128066 126980 -1086
==========================================
- Hits 100621 100504 -117
+ Misses 27445 26476 -969
🚀 New features to boost your workflow:
|
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.
What happened to using a WeakRef?
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.
Oh never mind I like this better
Changes Made
Fixes the
issues
Related Issues
Checklist
docs/mkdocs.yml
navigation