A small pid_max
value may cause applications to be accidentally killed when they are using a recycled PID.
This log shows that 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
If you check /proc/sys/kernel/pid_max
you may find kernel.pid_max = 32768
.
32768
is too small for some situations, particularly where PIDs are used up very fast and recycled quickly. For example, LiteSpeed may try to kill an unused lsphp process, but that PID may already have been recycled and reused as a MySQL (or other application) PID. When LiteSpeed kills the process, MySQL is killed unintentionally.
Increase pid_max
from 32768
to a larger number, such as 1048576
, like so:
sysctl kernel.pid_max kernel.pid_max = 32768 sysctl -w kernel.pid_max=1048576 kernel.pid_max = 1048576
NOTE:Sometimes the CRIU feature may cause similar trouble when it resets the PID to restore a process. This causes the PID to be reused too quickly, and can be a problem even with a large pid_max
setting.