Repository navigation
fix(session): free the transport when a session closes - #434
Merged
Merged
Conversation
`ResultReaderFactory` held a strong `Arc<dyn Transport>` back to the `SeaRestTransport` that owns it, so the two formed a reference cycle and the transport was never dropped. Every closed session leaked its transport, HTTP client and tokio runtime handle. The Python binding runs one tokio runtime per session, and a live handle keeps that runtime's IO driver open after shutdown: two epoll fds, one eventfd and one signal socket per closed session, until the process hits `Too many open files`. The factory now holds a `Weak` reference and upgrades it when it builds a CloudFetch or inline-streaming reader. Readers keep a strong reference, so an open result stream still works after `Session::close`. Signed-off-by: cathleeny <58714163+cathleeny@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
cathleeny
requested review from
a team,
deeksha-db,
shivam2680 and
vuanhphung
November 10, 2026 21:43
vuanhphung
approved these changes
Nov 10, 2026
Collaborator
|
There's a similar issue of OAuth providers still retain the HTTP client and form a cycle, which can be fixed separately |
cathleeny
enabled auto-merge
November 10, 2026 22:32
vuanhphung
pushed a commit
that referenced
this pull request
Nov 20, 2026
Dependency from PR #434 (e8920d8), adapted to current main. Exclusive HTTP-pool checkout needs the transport-reader cycle broken so closed sessions can return their clients. Signed-off-by: cathleeny <58714163+cathleeny@users.noreply.github.com> Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Resolve the NEXT_CHANGELOG.md conflict by keeping the entries from both sides. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: cathleeny <58714163+cathleeny@users.noreply.github.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Nit
Looks good, with 1 low concern. Switching the factory to a Weak reference breaks the cycle. The factory is reachable only through the transport's &self and there is no Drop path that uses it, so upgrade() cannot fail while the factory is in use.
Other findings
- ⚪ Nit — The new test covers only open and close with no statement run. It doesn't cover a result stream that outlives
Session::close, which should keep working and free the transport once dropped. Add a wiremock test that runs a statement, closes the session, reads the stream, drops it, and assertsupgrade().is_none(). (Found by Claude Opus 5.5 · confirmed by the judge)
vuanhphung
added a commit
that referenced
this pull request
Nov 20, 2026
Keep the original entry from #434 and remove this branch duplicate. Verified that exactly one transport-cycle entry remains and the reuse opt-out documentation is preserved. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
vuanhphung
added a commit
that referenced
this pull request
Nov 22, 2026
Keep the original entry from #434 and remove this branch duplicate. Verified that exactly one transport-cycle entry remains and the reuse opt-out documentation is preserved. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
This branch was previously deployed
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.
Bug: Closing a
Sessionnever freed its transport.ResultReaderFactoryheld a strongArc<dyn Transport>back to theSeaRestTransportthat owns it, so the two formed a reference cycle. The Python binding runs one tokio runtime per session, and the leaked runtime handle keeps that runtime's IO driver FDs open, so a customer on 1.3.0 hitOSError: [Errno 24] Too many open files.Changes:
Weakreference and upgrades it when it builds a CloudFetch or inline-streaming reader.Session::closekeeps working.Testing
close_releases_transporttest opens and closes a session against wiremock and asserts the transport is dropped. It fails onmainand passes with this change./proc/self/fd. OnmainFDs grew by 120 (60 epoll, 30 eventfd, 30 socket, four per session); with this change they grew by 0.cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo testpass locally on Rust 1.97.1.