Repository navigation
Add staged test insertion APIs for Java tree and table sessions - #19308
Open
hongzhi-gao wants to merge 4 commits into
Open
hongzhi-gao wants to merge 4 commits into
hongzhi-gao wants to merge 4 commits into
Conversation
Caideyipi
requested changes
Nov 18, 2026
| throws IoTDBConnectionException, StatementExecutionException { | ||
| Objects.requireNonNull(stage, SessionMessages.EXCEPTION_STAGE_9A8C2B9D); | ||
| TSInsertTabletReq request = genTSInsertTabletReq(tablet, false, false); | ||
| request.setWriteToTable(true); |
Collaborator
There was a problem hiding this comment.
genTSInsertTabletReq returns null when SessionUtils.filterNullColumns removes every FIELD column. This path dereferences that null request, so a staged table-model tablet containing only all-null FIELD columns throws a client-side NullPointerException before the RPC. Please handle the filtered-empty case explicitly and cover it in a test; the tree staged tablet overloads also lack explicit handling for a filtered-empty request.
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
Existing tree-model test insertion APIs only acknowledge reception by the server. This PR adds explicit completion stages so callers can exercise decoding, read-only analysis, distributed planning, and delivery to write targets without inserting data or changing metadata.
Public Java APIs
Add eight stage-aware overloads to
ISession/Session:testInsertTablet(Tablet, TestInsertStage)andtestInsertTablet(Tablet, boolean sorted, TestInsertStage).testInsertTablets(Map<String, Tablet>, TestInsertStage)and the overload withboolean sorted.testInsertRecordwith a trailingTestInsertStage, for both string values and explicit data types/values.testInsertRecordswith a trailingTestInsertStage, for both batched string values and explicit data types/values.Add
ITableSession.testInsert(Tablet)andITableSession.testInsert(Tablet, TestInsertStage), implemented byTableSessionand pooled table sessions. The default table overload stops atUNTIL_RPC_PROCESSED.Session.testInsertRelationalTablet(Tablet, TestInsertStage)provides the underlying table-model implementation. Existing tree-model overloads retain their behavior.Completion boundaries
UNTIL_RPC_PROCESSEDUNTIL_DECODEDUNTIL_ANALYZEDUNTIL_PLANNEDUNTIL_WRITE_TARGET_RECEIVEDFor example, given an existing table/device, unchanged attributes and a data partition covering the tablet timestamps:
Queries return the same rows after each call. If analysis would require a new device, an attribute update, schema creation, or a new data partition, analysis and later stages fail instead of performing that change.
Execution and compatibility
testInsert(TSTestInsertReq), responseTSTestInsertResp, andTestInsertStage.testInsertPlanNodes(TSendBatchPlanNodeReq)for target validation. Separate RPCs prevent older nodes from silently ignoring a test flag and executing a write.StatementExecutionException, matching the staged record APIs, before any RPC. Preserve the column categories generated for the filtered table-model payload.finally.Targets are checked sequentially. This API does not establish WAL durability, replication success, or production write-throughput performance.
Validation
with-zh-locale.IoTDBStagedTestInsertITcases passed on 1C1D and 1C3D before the final client fix. That fix was verified with unit tests and live-server checks; the JUnit IT suite was not rerun.Table Session request latency
Measured at
eb0c06d69fon 2026-11-18: a separate WSL client called a remote 1C3D deployment (all nodes on one server, three replicas). One thread reused a connection; each Tablet contained one device, one TAG and three FIELDs. Each stage/batch size had 500 warmups and 3 × 1,000 measured calls.Times cover
tableSession.testInsert(tablet, stage), including client encoding, network and server processing; connection setup and Tablet construction are excluded. All 30,000 measured requests succeeded, with stored data unchanged.UNTIL_RPC_PROCESSEDUNTIL_DECODEDUNTIL_ANALYZEDUNTIL_PLANNEDUNTIL_WRITE_TARGET_RECEIVEDA separate 100-packet ICMP measurement on the same client/server path gave RTT mean 3.045 ms, P50 2.120 ms, P95 8.170 ms, with no packet loss. It was collected after the API test and is not subtracted from the API timings. These results describe this environment, not isolated phase costs or normal-write throughput.
Review
Independent source review covered metadata mutation paths, partition lookup, target validation, memory/lock cleanup and pool synchronization. A locale-dependent assertion was corrected to use the localized message constant.
This PR has:
Key changed classes
ISession,ITableSession,Session,SessionConnection,TableSession,TableSessionWrapper,ClientRPCServiceImpl,Coordinator,MPPQueryContext,ClusterPartitionFetcher, schema validators andTestInsertPlanValidator.