This is an old revision of the document!
Small pid_max may cause MySQL using recybled pid accidentally killed
MySQL was accidentally killed somehow. When tracing the root cause, seem LiteSpeed killed mysql:
[Wed Mar 20 04:11:42 2019] SIGTERM to mysqld (12289) by litespeed (6133),0,99 <- systemd (1),0,0 [Wed Mar 20 04:11:49 2019] SIGTERM to mysqld (12289) by mysqld (12289),994,991 <- mysqld_safe (12121),0,0 <- systemd (1),0,0
Check /proc/sys/kernel/pid_max
and it is kernel.pid_max = 32768
at the moment.
32768
is too small for some situation when pids are used up very fast and recycled quickly. LiteSpeed may try to kill the unused lsphp process but that pid may have been recycled and reuse as a mysql pid, exim pid or other applications, which might cause mysql or other application was killed accidentally. Sometimes CRIU feature may cause such trouble as well since as it reset the PID to restore a process, causing PID being reused too fast even with large pid_max.
The fix is to increase the pid_max
from '32768' to a larger number such as 1048576
:
sysctl kernel.pid_max
kernel.pid_max = 32768
sysctl -w kernel.pid_max=1048576
kernel.pid_max = 1048576