ColinLeeo opened a new pull request, #18842: URL: https://github.com/apache/iotdb/pull/18842
## Description Fix a Python client bug that swaps `sessionId` and `statementId` when constructing query result sets. `execute_query_statement`, `execute_statement`, and `execute_raw_data_query` send the correct IDs in the initial execution request, but pass them in reverse order to `SessionDataSet`. Subsequent `fetchResultsV2` and `closeOperation` requests therefore use the wrong IDs. `execute_last_data_query` already uses the correct order. ### Compatibility with newer IoTDB servers Older Python client versions containing this bug can fail when connecting to IoTDB servers with the query ownership validation introduced by #18643. When `sessionId != statementId`, the initial result batch can be returned successfully, but fetching the next batch is rejected with `NO_PERMISSION` because the supplied statement ID does not own the query. Closing a query before all results have been consumed can also be rejected while the query is still running. If the two IDs happen to be equal, the swap is invisible. This explains why simple connections and existing tests may appear to work, while other connection/statement allocation histories expose the problem. The server validation exposes an existing client bug; users encountering this combination need a Python client containing this fix. Upgrading only the server does not correct the IDs sent by an older client. ### Changes - Pass `SessionDataSet` arguments by name in all four query entry points, assigning the correct connection `session_id` and `statement_id` explicitly. - Add 16 regression scenarios using deliberately different session and statement IDs. Cover all four entry points, fetching another result batch, closing before exhaustion, and retrying query execution after reconnecting with a new client and new IDs. - Keep the public client API and server-side query ownership checks unchanged. ## Validation - Before the fix, the new regression suite reproduced 12 failures in the three affected entry points; the four latest-value query scenarios passed. - Python unit suite: `python3 -m pytest tests/unit -q --tb=short` — 50 passed. - Black check on the changed Python files and `git diff --check` passed. - Live-server integration tests were not run; regression tests exercise the actual dataset iteration, TsBlock deserialization, and reconnect paths, and inspect the Thrift request IDs using mocked RPC clients. This PR has: - [x] been self-reviewed. - [x] added unit tests to cover the corrected behavior. ##### Key changed/added classes - `iotdb.Session.Session` - `tests/unit/test_session_query_ids.py` -- 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]
