Commit ea18076
Fix deadlock in NamespacedHierarchicalStore.computeIfAbsent() (#5348)
In #5231 evaluation of the default value creator was deferred until
after an entry was created in the concurrent hash map backing the store.
This enables recursive updates. However, by calling `evaluateIfNotNull`
inside `compute` threads that lost the race would wait inside
`Map::compute` for the value to be evaluated.
Waiting here is a problem when the backing concurrent hashmap is
reaching capacity. The thread waiting inside compute holds a lock while
at the same time the thread that won the race will try to acquire a lock
to resize the map.
By making the threads that lost the race wait outside of `Map::compute`
we can prevent this dead lock. This does require that each thread
retries when another thread failed to insert a value. But eventually
either one other thread either successfully inserts a value or the
thread uses its own default value creator.
Fixes: #5346
Co-authored-by: Marc Philipp <mail@marcphilipp.de>
(cherry picked from commit f29de38)1 parent 869e232 commit ea18076
File tree
3 files changed
+137
-35
lines changed- documentation/modules/ROOT/partials/release-notes
- junit-platform-engine/src/main/java/org/junit/platform/engine/support/store
- platform-tests/src/test/java/org/junit/platform/engine/support/store
3 files changed
+137
-35
lines changedLines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
Lines changed: 87 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | 226 | | |
237 | | - | |
238 | | - | |
239 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
240 | 258 | | |
241 | | - | |
242 | 259 | | |
243 | 260 | | |
244 | 261 | | |
| |||
269 | 286 | | |
270 | 287 | | |
271 | 288 | | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
277 | 316 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | 317 | | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
293 | 326 | | |
294 | | - | |
295 | 327 | | |
296 | 328 | | |
297 | 329 | | |
| |||
488 | 520 | | |
489 | 521 | | |
490 | 522 | | |
| 523 | + | |
| 524 | + | |
491 | 525 | | |
492 | 526 | | |
493 | 527 | | |
| |||
518 | 552 | | |
519 | 553 | | |
520 | 554 | | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
521 | 560 | | |
522 | 561 | | |
523 | 562 | | |
| |||
546 | 585 | | |
547 | 586 | | |
548 | 587 | | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
549 | 593 | | |
550 | 594 | | |
551 | 595 | | |
| |||
580 | 624 | | |
581 | 625 | | |
582 | 626 | | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
583 | 632 | | |
584 | 633 | | |
585 | 634 | | |
| |||
670 | 719 | | |
671 | 720 | | |
672 | 721 | | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
673 | 726 | | |
674 | 727 | | |
675 | 728 | | |
| |||
Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
431 | 432 | | |
432 | 433 | | |
433 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
434 | 459 | | |
435 | 460 | | |
436 | 461 | | |
| |||
446 | 471 | | |
447 | 472 | | |
448 | 473 | | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
449 | 497 | | |
450 | 498 | | |
451 | 499 | | |
| |||
0 commit comments