Modifying MariaDB process limits - Avoiding connectivity problems

jtorrex

2020/06/25

Categories: blog sysadmin databases Tags: mysql mariadb linux troubleshooting

Description:

Few time ago a researcher reports me that their server with a MariaDB instance was refusing their connections. After some tests with unsuccesful results, we found a workaround modifing the process limits to grant again connectivity to the instance.

Procedure

root@linux:# telnet sql-node1 3306
Trying 192.168.0.10...
Connected to sql-node1.
Escape character is '^]'.
Connection closed by foreign host.
2020-05-10 16:20:23 140123042092800 [ERROR] Invalid (old?) table or database name 'mysql-files'
2020-05-10 16:20:57 140123756480704 [ERROR] Error in accept: Too many open files
2020-05-10 16:25:13 140123756480704 [ERROR] Error in accept: Too many open filesb' user: 'phyReader' host: 'node1' (Got timeout reading communication packets)
sql-node1:# mysql -u root -p

MariaDB [(none)]> SHOW VARIABLES LIKE 'open%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| open_files_limit | 4186  |
+------------------+-------+
1 row in set (0.03 sec)

MariaDB [(none)]> quit
Bye

http://blogs.reliablepenguin.com/2015/08/28/mariadb-on-centos-7-error-in-accept-too-many-open-files

sql-node1:# ps -elaf | grep mysql
4 S mysql     6502     1  0  80   0 - 518769 SyS_po 08:50 ?       00:00:00 /usr/sbin/mysqld --defaults-file=/etc/my.cnf --user=mysql
4 S root      6555  5797  0  80   0 -  1858 -      08:52 pts/0    00:00:00 grep --color=auto mysql
sql-node1:# cat /proc/6502/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        unlimited            unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             14219                14219                processes
Max open files            4186                 4186                 files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       14219                14219                signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us
Max open files            4186                 4186                 files
sql-node1:# vim /usr/lib/systemd/system/mariadb.service
LimitNOFILE=infinity
sql-node1:# systemctl daemon-reload
sql-node1:# systemctl restart mysql
sql-node1:# ps -elaf | grep mysql
4 S mysql     6630     1  3  80   0 - 452932 SyS_po 08:53 ?       00:00:00 /usr/sbin/mysqld --defaults-file=/etc/my.cnf --user=mysql
4 S root      6673  5797  0  80   0 -  1858 -      08:53 pts/0    00:00:00 grep --color=auto mysql
sql-node1:# cat /proc/6630/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        unlimited            unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             14219                14219                processes
Max open files            1048576              1048576              files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       14219                14219                signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us
root@linux:# telnet sql-node1 3306
Trying 192.168.0.10...
Connected to sql-node1.
Escape character is '^]'.