feat(sf_core): atomically take result streams - #1342
Open
zeroshade wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a one-shot result-set streaming API to make result-set handle consumption atomic and failure-safe, reducing duplicate acquire/release logic across callers and tightening concurrency semantics around handle ownership.
Changes:
- Added
DatabaseDriverV1::result_set_take_streamto atomically deregister a result-set handle before building its Arrow reader, ensuring the handle stays released even on construction failure. - Introduced
HandleManager::take_objas an internal primitive to implement first-caller-wins consumption under a single write lock. - Refactored stream construction to be shared between
result_set_get_stream(retained handle) andresult_set_take_stream(consuming handle), and migratedstatement_prepareto the consuming lifecycle.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
sf_core/src/handle_manager.rs |
Adds atomic handle consumption via take_obj, and re-implements delete_handle on top of it. |
sf_core/src/apis/database_driver_v1/statement.rs |
Switches statement_prepare to use the new one-shot result-set streaming API. |
sf_core/src/apis/database_driver_v1/result_set.rs |
Extracts shared stream construction and adds result_set_take_stream plus targeted tests for consumption and failure cleanup. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
sf_core/src/handle_manager.rs:116
HandleManager::delete_handleno longer creates its own tracing span, which makes it inconsistent with the rest ofHandleManager’s public methods (add_handle,get_obj,drain_matching) and also means delete operations will only show up under the nestedHandleManager::take_objspan. Adding aHandleManager::delete_handlespan keeps traces searchable and preserves the method-level observability that the other operations have.
pub fn delete_handle(&self, handle: Handle) -> bool {
self.take_obj(handle).is_some()
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DatabaseDriverV1::result_set_take_stream, a one-shot API that atomically deregisters a result-set handle before constructing its Arrow readerHandleManager::take_objprimitive so concurrent consumers are first-caller-wins under one write lockresult_set_get_streamand consumingresult_set_take_streamstatement_prepareto the one-shot lifecycleMotivation
In-process wrappers currently repeat this lifecycle in execution, metadata, and ingestion paths:
result_set_get_streamresult_set_releaseon successThe new method centralizes that ownership transition in sf_core. The Rust ADBC driver can replace its shared acquire/release helper with one
result_set_take_streamcall, while protobuf clients retain the existing independent get/release methods.Semantics
result_set_get_streamresult_set_get_streamremains reusable and backward compatibleTesting
cargo test -p sf_core --lib -- --test-threads=1— 1700 passed, 1 ignoredcargo check -p sf_core --all-targetscargo check -p sf_core --no-default-featurescargo clippy -p sf_core --libcargo doc -p sf_core --no-depscargo fmt --all -- --checkgit diff --checkThe full suite was run serially because existing resolver tests mutate process environment and can race under the default parallel test runner.