JackieTien97 opened a new pull request, #17712:
URL: https://github.com/apache/iotdb/pull/17712
## Summary
Fixes two intermittent failures in `ut-datanode` after #17698 enabled
`forkCount=4`:
1. **`DataRegionTest.tearDown:165` — `failed to close some ports`**
`EnvironmentUtils.examinePorts()` checks 6667 / 5555 / 31999 / 9091
machine-wide via `connect()`. `DataNodeInternalRPCServiceImplTest` legitimately
binds 6667 through `DataRegionConsensusImpl.start()` →
`IoTConsensusRPCService`. A sibling fork's tearDown then sees 6667 open and
fails — a cross-fork false positive, not a real leak.
#17698 missed this because its grep for `ServerSocket / bind() /
TServer.serve()` doesn't catch the binding done indirectly via
`IConsensus.start()`.
2. **`AlignedSeriesScanOperatorTest.batchTest2:423` — NPE on null TsBlock**
`FullOuterTimeJoinOperator.next()` (and
`AbstractSeriesScanOperator.next()`) legitimately return `null` or an empty
TsBlock when `prepareInput()` yields on its 500ms `maxRunTime` slice. The test
dereferenced `tsBlock` immediately.
## Changes
- **`EnvironmentUtils.FORK_PORT_OFFSET = ((surefire.forkNumber - 1) % 30 +
1) * 1000`**
Each fork shifts its bound ports **and** the corresponding
`examinePorts()` check by this offset, so forks live in disjoint port
namespaces. `examinePorts()` in fork A only sees ports bound by fork A (real
leak detection preserved); fork A no longer sees fork B's bindings (cross-fork
false positive removed). Modulo 30 caps the offset so the highest checked port
(31999 + 30*1000 = 61999) stays valid.
- **`DataNodeInternalRPCServiceImplTest`** binds `6667 + FORK_PORT_OFFSET`
via the same constant — binding and check stay in sync.
- **`AlignedSeriesScanOperatorTest.batchTest1/2/3`** add `if (tsBlock ==
null || tsBlock.isEmpty()) continue;` after each `operator.next()`, matching
the pattern already used in `TreeTopKOperatorTest`,
`MergeTreeSortOperatorTest`, `TreeSortOperatorTest`, etc.
Audited `iotdb-core/datanode` UTs for other monitored-port bindings (`grep
-rE "(\W|^)(6667|5555|31999|9091)(\W|$)"`) — no other test binds any of these
ports. The only real binder is `DataNodeInternalRPCServiceImplTest`, which is
updated here.
## Test plan
- [ ] Spotless passes locally (`mvn spotless:check -pl iotdb-core/datanode`)
- [ ] `ut-datanode` CI job runs without "failed to close some ports" failures
- [ ] `AlignedSeriesScanOperatorTest.batchTest2` no longer NPEs
intermittently
- [ ] `DataNodeInternalRPCServiceImplTest` still passes (binding now on
fork-specific port)
--
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]