pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

pm2 cluster mode, 2 node going down together on error

Open singhmaheshk opened this issue 9 years ago • 8 comments

image

Expected behaviour

I am running a nodejs service on my local with pm2 cluster with 4 instances, I was testing, on error how the instance going down and comes online, I forced service to process.exit(1) on a error and I was expecting only one instance will go down but from the logs its showing two instances are going down together. check the attached image

Actual behaviour

two instance are going down together whenever there is node server going down on error. check the attached image

Steps to reproduce

Raised a error on a service method and on error event used process.exit(1) to shutdown the service instance.

Software versions used

OS         : OX X EI
node.js    : V6.4.0
PM2        : 2.3.0

singhmaheshk avatar Jan 24 '17 02:01 singhmaheshk

Can't reproduce with the setup you provided, are you sure that the second process isn't shutting down the same way to first one do ?

vmarchaud avatar Jan 24 '17 10:01 vmarchaud

Please find the more details. First started my service with pm2 in cluster mode with 4 instance, you can see in below screen, then I made few successful call for service, then I made a call to throw error, which is suppose to stop one instance, but its stopping two instance, you can see in screen shot.

in the below screen shot you can see two instance showing as restarted image

Here is screen shot of log file which is showing instance 0 and 1 got disconnected and then become online again.

image

I was expecting only one instance to go offline on an error.

singhmaheshk avatar Jan 25 '17 03:01 singhmaheshk

One additional info I would like to add here is, if I just ONLY call the method which throws error (No other method called since service has started) then it just take one instance down. But when I use any other service method and then call method which throws error then it start taking two instance down together.

singhmaheshk avatar Jan 25 '17 04:01 singhmaheshk

Are you using a browser to call the API? Because I've noticed that chrome might try the same path twice if it failed the first time..

EmmEm avatar Jan 26 '17 12:01 EmmEm

I am using Postman to call the service API. If Postman or Chrome is trying same path twice then it should always take 2 instance down, but the strange behavior is when i just call the API which throws error then it just take one instance down, and when I call any other API which return data and then call the API which throws error then from that point onwards it start taking two instances down.

singhmaheshk avatar Jan 26 '17 16:01 singhmaheshk

So the problem come from your code, otherwise the problem should have been consistent.

vmarchaud avatar Jan 26 '17 16:01 vmarchaud

I will do some more analysis and share the findings if this is causing by our code or something with pm2.

singhmaheshk avatar Jan 26 '17 17:01 singhmaheshk

Re-open if you have more information about this bug

vmarchaud avatar Feb 03 '17 14:02 vmarchaud