Homebrew installed MariaDb too many open files
MariaDB broken
It happened again.
I did brew update/upgrade
a while ago then weeks after that restarted MariaDB then days later tried to access MariaDB.
MariaDb too many open files
Trying to get info over the config file seems not easy.
ps -aef | grep maria
/usr/local/opt/mariadb/bin/mariadbd
--basedir=/usr/local/opt/mariadb
--datadir=/usr/local/var/mysql
--plugin-dir=/usr/local/opt/mariadb/lib/plugin
--log-error=/usr/local/var/mysql/Clemenss-MacBook-Pro.local.err
--open-files-limit=2048
--pid-file=Clemenss-MacBook-Pro.local.pid
Open files == 2048 ?
Brew config for MariaDB
Reading output from
brew services --help
Global it is not but let's check for sure
ls -l /Library/LaunchDaemons/
is interestingly showing OLD stuff but no MariaDb.
User specific
ls -l ~/Library/LaunchAgents/
...
homebrew.mxcl.mariadb.plist
contains
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.mariadb</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/mariadb/bin/mysqld_safe</string>
<string>--datadir=/usr/local/var/mysql</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local/var</string>
</dict>
</plist>
That content does not match the result from the ps
command ... huh?!?
brew services --debug --verbose start mariadb
showed indeed the same configuration.
Start MariaDB manually
Let's try to start from the command-line having `--open-files-limit=8192*
brew services stop mariadb
/usr/local/opt/mariadb/bin/mariadbd --basedir=/usr/local/opt/mariadb --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/opt/mariadb/lib/plugin --log-error=/usr/local/var/mysql/Clemenss-MacBook-Pro.local.err --open-files-limit=8192 --pid-file=Clemenss-MacBook-Pro.local.pid
2020-11-13 11:32:59 0 [Note] /usr/local/opt/mariadb/bin/mariadbd (mysqld 10.5.5-MariaDB) starting as process 73990 ...
2020-11-13 11:32:59 0 [Warning] Could not increase number of max_open_files to more than 256 (request: 32190)
2020-11-13 11:32:59 0 [Warning] Changed limits: max_open_files: 256 max_connections: 151 (was 151) table_cache: 200 (was 2000)
2020-11-13 11:32:59 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
Make sure to kill mariadb nicely.
Fixing
Requires the following
Make ulimit settings system wide
launchctl limit maxfiles 30000 unlimited
vi /Library/LaunchDaemons/limit.maxfiles.plist
vi /Library/LaunchDaemons/limit.maxproc.plist
Add the same to your shell environment
launchctl limit maxfiles
maxfiles 256 unlimited
The answer is puzzling ... the hard limit is unlimited.
Soft limits of 256 seems a little few for a database server
SELECT @@open_files_limit;
+--------------------+
| @@open_files_limit |
+--------------------+
| 256 |
+--------------------+
or IMHO nicer
SHOW VARIABLES LIKE 'open_files_limit';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| open_files_limit | 256 |
+------------------+-------+