Repository navigation
Conversation
…are exhausted callWithRetryAndReconnect returned a null result after all attempts failed with a TException. Callers dereferenced it and threw a NullPointerException, losing the real cause. SessionPool treated the NPE as a RuntimeException and put the broken session back into the pool, so every later call failed the same way until the client JVM was restarted. Throw IoTDBConnectionException with the last TException as the cause, so the error is diagnosable and SessionPool evicts the broken session.
yamass
force-pushed
the
fix/session-npe-on-exhausted-retries
branch
from
October 7, 2026 10:30
77a0ce3 to
86b842c
Compare
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The shared fix correctly preserves the root cause and is covered across direct and pooled session paths.
Review effort: Balanced
Findings: None
What changed in this PR
Ensures exhausted Session RPC retries preserve the underlying Thrift failure as an IoTDBConnectionException.
Changes:
- Throws a connection exception when retries produce no result.
- Adds query, status-path, and pool-eviction regression tests.
| File | Description |
|---|---|
SessionConnection.java |
Converts exhausted retry failures into connection exceptions. |
BrokenSessionConnectionTest.java |
Tests cause preservation and broken-session eviction. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Description
Problem
When every attempt in
SessionConnection.callWithRetryAndReconnectfails with aTException, it returns aRetryResultwith a null result. Its callers (queries,TSStatusmethods, schema template methods) use the result without checking it and throw aNullPointerException:As a result:
TTransportException: Cannot write to null outputStream) is lost.SessionPoolhandles the NPE in itsRuntimeExceptionbranch and puts the broken session back at the head of its queue, so the next call gets the same session. As long as that session cannot reconnect, each call fails the same way. We saw this continue until the client JVM was restarted.Fix
callWithRetryAndReconnectnow throwsIoTDBConnectionException(lastTException)when no attempt produced a result. The result can only be null if the last attempt threw, so the cause is always set.SessionPoolnow takes its existingIoTDBConnectionExceptionbranch, which closes the broken session and creates a new one.Tests
New
BrokenSessionConnectionTestuses a real, closed Thrift transport and an unreachable reconnect target. It checks thatexecuteQueryStatementandsetStorageGroupthrowIoTDBConnectionExceptionwith the cause attached, and that a broken connection leads to a session eviction. These tests fail onmasterand pass with this change. Alliotdb-sessionunit tests pass.This PR has:
Key changed/added classes (or packages if there are too many classes) in this PR
iotdb-client/session:SessionConnection,BrokenSessionConnectionTest(new)