Commit d67d18e
authored
fix(ci): race conditions in tests (#119)
* fix: race condition in TestFindProviders
the test was incorrectly using require.Eventually on already-read results.
also, parallelRouter doesn't deduplicate, so peers[0] can appear twice
(once with addresses from mr1, once without from mr2). fixed by searching
for the record with addresses before verifying filtration.
* fix: deadlock in manyIter.Close()
manyIter.Close() would deadlock when goroutines were blocked
on unbuffered channel sends. fixed with synchronous drain that
matches http streaming semantics from routing v1 spec:
- idempotent close (safe to call multiple times)
- drain channel to unblock senders (expected for early termination)
- proper cleanup of child iterators
also added missing defer it.Close() in tests.
* fix: deadlock in cacheFallbackIter
dispatchFindPeer goroutines blocked forever trying to send to
unbuffered channel when iterator closed early.
fixed with buffered channel + non-blocking sends that drop
results if nobody is reading (acceptable for background lookups).
also added context cancellation in Close() to stop goroutines.
* fix: add missing iterator Close() calls in tests
added defer it.Close() to all test iterators to prevent
resource leaks that could cause intermittent hangs.
* fix: infinite recursion in cacheFallbackIter.Next()
replaced recursion with loop to avoid stack overflow.
maintains original logic: after dispatching lookup for
peer without addresses, continues trying source iterator
or waiting for lookup results.
also fixed deadlock when ongoingLookups reaches 0 between
check and channel read by using periodic timeout.
* refactor: simplify cacheFallbackIter.Next()
- removed unnecessary handleRecord closure
- cache ongoingLookups value to avoid race in logging
- use defer timer.Stop() for proper cleanup
* fix: resource leak and double-close issues
- fix iterator leak in dispatchFindPeer by adding defer Close()
- remove redundant goroutine in manyIter.Close() that could
cause double-close panic. the channel is already closed by
the goroutine in newManyIter.1 parent 95b801a commit d67d18e
3 files changed
Lines changed: 111 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
126 | 130 | | |
127 | 131 | | |
128 | 132 | | |
129 | | - | |
130 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
131 | 136 | | |
132 | 137 | | |
133 | 138 | | |
134 | 139 | | |
135 | 140 | | |
136 | 141 | | |
137 | 142 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
146 | 166 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 167 | + | |
| 168 | + | |
155 | 169 | | |
156 | 170 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
162 | 176 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | 177 | | |
167 | | - | |
168 | | - | |
169 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
170 | 184 | | |
171 | 185 | | |
172 | 186 | | |
| |||
175 | 189 | | |
176 | 190 | | |
177 | 191 | | |
178 | | - | |
179 | | - | |
180 | 192 | | |
| 193 | + | |
181 | 194 | | |
182 | 195 | | |
| 196 | + | |
| 197 | + | |
183 | 198 | | |
184 | 199 | | |
185 | | - | |
186 | | - | |
187 | 200 | | |
188 | 201 | | |
189 | 202 | | |
| |||
194 | 207 | | |
195 | 208 | | |
196 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
197 | 216 | | |
198 | 217 | | |
199 | 218 | | |
| |||
207 | 226 | | |
208 | 227 | | |
209 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
210 | 232 | | |
211 | 233 | | |
212 | 234 | | |
213 | 235 | | |
214 | 236 | | |
215 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
216 | 252 | | |
217 | | - | |
| 253 | + | |
218 | 254 | | |
219 | 255 | | |
220 | 256 | | |
221 | 257 | | |
222 | | - | |
| 258 | + | |
223 | 259 | | |
224 | 260 | | |
225 | 261 | | |
226 | 262 | | |
227 | | - | |
| 263 | + | |
228 | 264 | | |
229 | | - | |
| 265 | + | |
230 | 266 | | |
231 | 267 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
198 | 201 | | |
199 | | - | |
200 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
201 | 212 | | |
202 | 213 | | |
203 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
300 | 299 | | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| 341 | + | |
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
344 | 345 | | |
345 | 346 | | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
350 | 366 | | |
351 | 367 | | |
352 | 368 | | |
| |||
389 | 405 | | |
390 | 406 | | |
391 | 407 | | |
| 408 | + | |
392 | 409 | | |
393 | 410 | | |
394 | 411 | | |
| |||
405 | 422 | | |
406 | 423 | | |
407 | 424 | | |
408 | | - | |
409 | 425 | | |
| 426 | + | |
410 | 427 | | |
411 | 428 | | |
412 | 429 | | |
| |||
439 | 456 | | |
440 | 457 | | |
441 | 458 | | |
| 459 | + | |
442 | 460 | | |
443 | 461 | | |
444 | 462 | | |
| |||
484 | 502 | | |
485 | 503 | | |
486 | 504 | | |
| 505 | + | |
487 | 506 | | |
488 | 507 | | |
489 | 508 | | |
| |||
0 commit comments