cluster: ignore queryServer msgs on disconnection
authorSantiago Gimeno <santiago.gimeno@gmail.com>
Tue, 29 Dec 2015 09:21:55 +0000 (10:21 +0100)
committerMyles Borins <mborins@us.ibm.com>
Mon, 15 Feb 2016 19:30:23 +0000 (11:30 -0800)
commitb8213ba7e16a1833768bb6aeadab7db89e3dedbd
tree63f24765c34d5e4c55e6011a29f7783b2045c8c5
parent1bb2967d48ecfd53cf6dd9d340392e017426ab6b
cluster: ignore queryServer msgs on disconnection

It avoids the creation of unnecessary handles. This issue is causing
intermitent failures in `test-cluster-disconnect-race` on `FreeBSD`
and `OS X`.

The problem is that the `worker2.disconnect` is being called on the
master before the `queryServer` is handled, causing the worker to
be deleted, then the Server handle is created afterwards. Later on,
when `removeWorker` is called from the `exit` handler, there are no
workers left, but one handle, thus the `AssertionError`.

Add a new `test/sequential/test-cluster-disconnect-leak` based on
`test-cluster-disconnect-race` that creates lots of workers and fails
consistently without this patch.

PR-URL: https://github.com/nodejs/node/pull/4465
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Rich Trott <rtrott@gmail.com>
lib/cluster.js
test/sequential/test-cluster-disconnect-leak.js [new file with mode: 0644]