Simple Machines Community Forum

SMF Support => Server Performance and Configuration => Topic started by: boardhead on February 06, 2018, 11:29:24 AM

Title: "SMF Database Error!" after upgrading to MacOS High Sierra [solved]
Post by: boardhead on February 06, 2018, 11:29:24 AM
After upgrading my MacOS system from Yosemite (10.10.5) to High Sierra (10.13.3), I was getting occasional bursts of "SMF Database Error!" emails with this message:

This is a notice email to let you know that SMF could not connect to the database, contact your host if this continues.

Along with the new operating system, MySQL was also updated from 5.6.21 to 5.7.21, so I don't know which upgrade caused the problem, but I'm guessing MySQL.

Checking the MySQL log file (/usr/local/mysql/data/mysqld.local.err) I saw lots of messages like this:

[Warning] File Descriptor 1027 exceeded FD_SETSIZE=1024

It turns out there is a hard limit of 1024 on the maximum number of file descriptors for High Sierra.  The solution was to edit /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist and add this line to the mysqld options:

<string>--table-open-cache=400</string>

Then restart MySQL by clicking "Stop MySQL Server" then "Start MySQL Server" in the MySQL System Preferences.

The default setting for table-open-cache was 2000, which was greater than the MacOS limit.  Decreasing this to 400 has fixed my database error problems without any noticeable averse effects.

- Phil
Title: Re: "SMF Database Error!" after upgrading to MacOS High Sierra [solved]
Post by: LiroyvH on February 06, 2018, 12:16:14 PM
Thanks for sharing the solution :) Some people might find that useful!
Title: Re: "SMF Database Error!" after upgrading to MacOS High Sierra [solved]
Post by: boardhead on February 06, 2018, 01:48:35 PM
Here are a few commands that might find useful in diagnosing this problem:

1. Show your current table_open_cache setting:

mysqladmin -u mysql -p variables | grep -w table_open_cache

(and enter your mysql password)

2. Count the number of currently open tables:

sudo lsof -p <pid> | grep MYD | wc -l

(and enter your user password.  <pid> is the process ID number for mysqld)

3. Show your current mysqld version:

mysqld --version

- Phil
Title: Re: "SMF Database Error!" after upgrading to MacOS High Sierra [solved]
Post by: joshuapinter on October 12, 2018, 12:21:35 AM
Hey Phil,

I created an account on here just to let you know that you saved the day by pointing out that the value of `table_open_cache` should be _less_ than the default of 2000, instead of more.

I've spent days tracking down this bug and your tip was the answer. Settled on a value of 900, which works great.

Thank you so much for posting this! :)

Joshua