JackieTien97 opened a new pull request, #18078: URL: https://github.com/apache/iotdb/pull/18078
## Problem When `IoTDBStatement.reConnect()` runs (e.g. a DataNode is restarted mid-query), `this.sessionId` and `this.stmtId` are refreshed — but the retry lambda still sends the originally-built `TSExecuteStatementReq` carrying the **old** session/statement ids. On the server side, `ClientRPCServiceImpl.executeStatementInternal` resolves the session from the **current RPC connection** (`getCurrSessionAndUpdateIdleTime()`) while taking the `statementId` from the **request body**. After reconnect that yields new-session + old-statement-id, so `ClientSession.addQueryId` throws: > StatementId: N doesn't exist in this session which is mapped to `INTERNAL_SERVER_ERROR (305)`. This is the root cause of the recurring `query_restart_dn_show_dev` JDBC test failures: the test's `check_log_INTERNAL_SERVER_ERROR` greps the 305s and fails, even though the query results themselves are correct. ## Fix Refresh `sessionId` (and `statementId`) on the request object inside every retry lambda, mirroring `SessionConnection` in the Java Session SDK, which already handles this correctly. Affected methods in `IoTDBStatement`: - `executeSQL` (`executeStatementV2`) — sessionId + statementId - `executeQuerySQL` (`executeQueryStatementV2`) — sessionId + statementId - `executeUpdateSQL` (`executeUpdateStatement`) — sessionId + statementId - `executeBatchSQL` (`executeBatchStatement`) — sessionId (batch has no statement id) ## Verification - `mvn spotless:apply -pl iotdb-client/jdbc` — clean - `mvn compile -pl iotdb-client/jdbc` — BUILD SUCCESS 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
