Commit 9571be1
cluster: fix race condition setting suicide prop
There is no guarantee that the `suicide` property of a worker in the
master process is going to be set when the `disconnect` and `exit`
events are emitted.
To fix it, wait for the ACK of the suicide message from the master
before disconnecting the worker. Also, there's no need to send the
suicide message from the worker if the disconnection has been
initiated in the master.
Add `test-cluster-disconnect-suicide-race` that forks a lot of workers
to consistently reproduce the issue this patch tries to solve.
Modify `test-regress-GH-3238` so it checks both the `kill` and
`disconnect` cases. Also take into account that the `disconnect` event
may be received after the `exit` event.
PR-URL: #4349
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>1 parent 265e2f5 commit 9571be1Copy full SHA for 9571be1
File tree
Expand file treeCollapse file tree
3 files changed
+75
-28
lines changedOpen diff view settings
Filter options
- lib
- test
- parallel
- sequential
Expand file treeCollapse file tree
3 files changed
+75
-28
lines changedOpen diff view settings
Collapse file
+31-17Lines changed: 31 additions & 17 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
434 | 434 | |
435 | 435 | |
436 | 436 | |
437 | | - |
| 437 | + |
438 | 438 | |
439 | 439 | |
440 | 440 | |
| ||
445 | 445 | |
446 | 446 | |
447 | 447 | |
| 448 | + |
| 449 | + |
| 450 | + |
| 451 | + |
| 452 | + |
448 | 453 | |
449 | 454 | |
450 | 455 | |
| ||
541 | 546 | |
542 | 547 | |
543 | 548 | |
544 | | - |
| 549 | + |
545 | 550 | |
546 | 551 | |
547 | 552 | |
| ||
662 | 667 | |
663 | 668 | |
664 | 669 | |
| 670 | + |
| 671 | + |
| 672 | + |
| 673 | + |
| 674 | + |
| 675 | + |
| 676 | + |
| 677 | + |
| 678 | + |
| 679 | + |
| 680 | + |
| 681 | + |
| 682 | + |
| 683 | + |
| 684 | + |
| 685 | + |
665 | 686 | |
666 | 687 | |
667 | 688 | |
668 | 689 | |
669 | 690 | |
670 | 691 | |
671 | | - |
672 | | - |
| 692 | + |
| 693 | + |
| 694 | + |
| 695 | + |
| 696 | + |
| 697 | + |
| 698 | + |
| 699 | + |
673 | 700 | |
674 | 701 | |
675 | 702 | |
| ||
681 | 708 | |
682 | 709 | |
683 | 710 | |
684 | | - |
685 | | - |
686 | | - |
687 | | - |
688 | | - |
689 | | - |
690 | | - |
691 | | - |
692 | | - |
693 | | - |
694 | | - |
695 | | - |
696 | | - |
697 | 711 | |
698 | 712 | |
699 | 713 | |
|
Collapse file
test/parallel/test-regress-GH-3238.js
Copy file name to clipboardExpand all lines: test/parallel/test-regress-GH-3238.js+12-11Lines changed: 12 additions & 11 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
4 | 4 | |
5 | 5 | |
6 | 6 | |
7 | | - |
8 | | - |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
9 | 12 | |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
14 | 17 | |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
| 18 | + |
| 19 | + |
19 | 20 | |
20 | | - |
| 21 | + |
21 | 22 | |
Collapse file
test/sequential/test-cluster-disconnect-suicide-race.js
Copy file name to clipboard+32Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
0 commit comments