Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.46k stars 2.62k forks source link

Error pthread_create: Resource temporarily unavailable when having too many apps running #4951

Open MeMeMax opened 3 years ago

MeMeMax commented 3 years ago

What's going wrong?

I am running a Linux vServer which as 4 CPU vCore´s. I just added a new app running pm2 (now there are 5) and now I can´t stop or start any process. It just hangs here: [PM2] Applying action stopProcessId on app [affiliate-backend](ids: [ 1 ])

In the logs I saw this error message: pthread_create: Resource temporarily unavailable

Can I only run 4 apps when I have only 4 CPU cores? Is this a known problem?

How could we reproduce this issue?

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Sun Jan 03 2021 18:13:33 GMT+0100 (GMT+01:00)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.2.3
node version         : 12.18.3
node path            : not found
argv                 : /usr/local/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : nodejs
uid                  : 1000
gid                  : 1008
uptime               : 1min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.5.1
node version         : 12.18.3
node path            : /usr/local/bin/pm2
argv                 : /usr/local/bin/node,/usr/local/bin/pm2,report
argv0                : node
user                 : nodejs
uid                  : 1000
gid                  : 1008
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz
cpus nb              : 4
freemem              : 7021244416
totalmem             : 8589934592
home                 : /home/nodejs
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬─────────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name                    │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼─────────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 1   │ affiliate-backend       │ default     │ 0.0.1   │ fork    │ 1514     │ 61s    │ 0    │ online    │ 0%       │ 105.5mb  │ root     │ disabled │
│ 4   │ estimationpoker.de      │ default     │ 0.0.0   │ fork    │ 1534     │ 61s    │ 0    │ online    │ 0.7%     │ 122.8mb  │ root     │ disabled │
│ 2   │ festival-packlist.de    │ default     │ N/A     │ fork    │ 1520     │ 61s    │ 0    │ online    │ 0%       │ 54.8mb   │ nodejs   │ disabled │
│ 0   │ myhome.statsit          │ default     │ N/A     │ fork    │ 1561     │ 60s    │ 1    │ online    │ 0%       │ 11.1mb   │ root     │ disabled │
│ 3   │ word-detective.de       │ default     │ 0.0.1   │ fork    │ 1527     │ 61s    │ 0    │ online    │ 0%       │ 105.5mb  │ nodejs   │ disabled │
└─────┴─────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/nodejs/.pm2/pm2.log last 20 lines:
PM2        | 2021-01-03T18:12:31: PM2 log: BUS socket file      : /home/nodejs/.pm2/pub.sock
PM2        | 2021-01-03T18:12:31: PM2 log: Application log path : /home/nodejs/.pm2/logs
PM2        | 2021-01-03T18:12:31: PM2 log: Worker Interval      : 30000
PM2        | 2021-01-03T18:12:31: PM2 log: Process dump file    : /home/nodejs/.pm2/dump.pm2
PM2        | 2021-01-03T18:12:31: PM2 log: Concurrent actions   : 2
PM2        | 2021-01-03T18:12:32: PM2 log: SIGTERM timeout      : 1600
PM2        | 2021-01-03T18:12:32: PM2 log: ===============================================================================
PM2        | 2021-01-03T18:12:32: PM2 log: App [myhome.statsit:0] starting in -fork mode-
PM2        | 2021-01-03T18:12:32: PM2 log: App [myhome.statsit:0] online
PM2        | 2021-01-03T18:12:32: PM2 log: App [affiliate-backend:1] starting in -fork mode-
PM2        | 2021-01-03T18:12:32: PM2 log: App [festival-packlist.de:2] starting in -fork mode-
PM2        | 2021-01-03T18:12:32: PM2 log: App [affiliate-backend:1] online
PM2        | 2021-01-03T18:12:32: PM2 log: App [festival-packlist.de:2] online
PM2        | 2021-01-03T18:12:32: PM2 log: App [word-detective.de:3] starting in -fork mode-
PM2        | 2021-01-03T18:12:32: PM2 log: App [estimationpoker.de:4] starting in -fork mode-
PM2        | 2021-01-03T18:12:32: PM2 log: App [word-detective.de:3] online
PM2        | 2021-01-03T18:12:32: PM2 log: App [estimationpoker.de:4] online
PM2        | 2021-01-03T18:12:33: PM2 log: App [myhome.statsit:0] exited with code [0] via signal [SIGABRT]
PM2        | 2021-01-03T18:12:33: PM2 log: App [myhome.statsit:0] starting in -fork mode-
PM2        | 2021-01-03T18:12:33: PM2 log: App [myhome.statsit:0] online
seco35 commented 1 year ago

Experiencing the same behavior. Have you manage to solve this issue? I'm not able to start, stop or log the applications. It even goes so far that I can't use OS specific commands like: ls, ps, mkdir and so on. Trying to call ls or ps ends up showing me following error: 'bash fork retry resource temporarily unavailable'.

I do have 3 applications and 4 cores, so I don't think that the issue is related, to a maximum amount of applications limited to your core amount.

Would love to hear your solution if you have one so far...

Edit: Following dependencies are used in my project

"dependencies": { "axios": "^1.2.1", "cookie-parser": "^1.4.6", "express": "^4.18.1", "express-session": "^1.17.3", "mysql": "^2.18.1" }

Could you tell me which dependencies your applications are built on? Maybe this could be caused by some dependencies, when using it with pm2.