Commit 08d7dfe
committed
Fix flaky datanode UTs under parallel surefire forks
Two intermittent failures observed in ut-datanode (forkCount>1):
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. This was missed by #17698's premise
("zero ServerSocket / bind() / TServer.serve() calls in tests") because
the binding happens indirectly through 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.
Fixes:
- Introduce 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 in TreeTopKOperatorTest,
MergeTreeSortOperatorTest, TreeSortOperatorTest, etc.
Audited iotdb-core/datanode UTs for other monitored port bindings --
none beyond DataNodeInternalRPCServiceImplTest.1 parent 4ac0b7e commit 08d7dfe
3 files changed
Lines changed: 46 additions & 10 deletions
File tree
- iotdb-core/datanode/src/test/java/org/apache/iotdb/db
- queryengine/execution/operator
- service
- utils
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
143 | 146 | | |
144 | 147 | | |
145 | 148 | | |
| |||
420 | 423 | | |
421 | 424 | | |
422 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
423 | 429 | | |
424 | 430 | | |
425 | 431 | | |
| |||
727 | 733 | | |
728 | 734 | | |
729 | 735 | | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
730 | 739 | | |
731 | 740 | | |
732 | 741 | | |
| |||
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
| |||
109 | 115 | | |
110 | 116 | | |
111 | 117 | | |
112 | | - | |
| 118 | + | |
113 | 119 | | |
114 | 120 | | |
115 | 121 | | |
| |||
124 | 130 | | |
125 | 131 | | |
126 | 132 | | |
127 | | - | |
| 133 | + | |
| 134 | + | |
128 | 135 | | |
129 | 136 | | |
130 | 137 | | |
| |||
Lines changed: 28 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
99 | 110 | | |
100 | 111 | | |
101 | 112 | | |
| |||
174 | 185 | | |
175 | 186 | | |
176 | 187 | | |
177 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
178 | 197 | | |
179 | 198 | | |
180 | 199 | | |
181 | | - | |
| 200 | + | |
182 | 201 | | |
183 | 202 | | |
184 | 203 | | |
185 | 204 | | |
186 | 205 | | |
187 | 206 | | |
188 | 207 | | |
189 | | - | |
| 208 | + | |
190 | 209 | | |
191 | 210 | | |
192 | 211 | | |
193 | | - | |
| 212 | + | |
194 | 213 | | |
195 | 214 | | |
196 | 215 | | |
| |||
199 | 218 | | |
200 | 219 | | |
201 | 220 | | |
202 | | - | |
| 221 | + | |
| 222 | + | |
203 | 223 | | |
204 | | - | |
| 224 | + | |
205 | 225 | | |
206 | 226 | | |
207 | 227 | | |
208 | 228 | | |
209 | 229 | | |
210 | 230 | | |
211 | 231 | | |
212 | | - | |
213 | | - | |
| 232 | + | |
| 233 | + | |
214 | 234 | | |
215 | 235 | | |
216 | 236 | | |
| |||
0 commit comments