I have a problem where mysqld runs out of threads and throws errors when under heavy load. I have traced this back to a problem where the pid seems to be limited a soft limit of 1024 processes (have removed other limits for readability):
[root@db1 limits.d]# cat /proc/`pidof mysqld`/limits Limit Soft Limit Hard Limit Units Max processes 1024 191967 processes
I have a file in /etc/security/limits.d/ called 99-mysql.conf which contains:
mysql soft nofile 20000 mysql hard nofile 20000 mysql soft nproc 20000 mysql hard nproc 20000
As far as I can see the problem comes from MySQL being started by a user. I haven't tested this, but I assume that if MySQL is started by the system at boot time, then it should have the correct limits.
Is there a way to increase the soft limit for nproc for this pid and for future mysqld processes?