Too many open files

OS: This applies to OSX and Linux "Too many open files" is when a system is running low on resources and thus, running out of available filehandles, or when a process uses up all the filehandles that the OS allows.

So, there are 2 scopes. The entire system (so it will be reported in the system logs) or local process (so it will be reported in the local application logs).

Information to gather:

  1. Release of KMS. Be sure it is the latest.
  2. lsof > lsof.txt -- while the problem is happenign. Get the lsof.txt file.
  3. Enable "connections" debug logging.
  4. All appropriate log files.
  5. a SEGV crash dump.

Getting appropriate log files.

KMS: warning.log and error.log

System logs:
Mac: /var/log/system.log
Linux: /var/log/messages and /var/log/syslog


Cut-and-paste for Linux
Please do the following:

First:
Edit your /etc/init.d/keriomailserver

Change the following 1 line:

daemon $MAINDIR/mailserver $MAINDIR

To the following 2 lines:

ulimit -c unlimited
$MAINDIR/mailserver $MAINDIR >/dev/null 2>&1 &

Notice, I have taken out the "daemon" command, and added a "ulimit" command before this line.

Now, restart the mailserver. Next time it happens, please get the following:

lsof > lsof.txt
kill -SEGV ####

Where #### is the PID of the mailserver process. This can be obtained using the "top" command or the "ps" command. The kill command will create a core file in /opt/kerio/mailserver called core.#### where #### is the same number you killed up above. Please do the following using your GDB command:

First, please enable "Connections" debug logging.  Right-click over the debug log, then choose "Set log events..." or "Messages..." then choose "Network Connections and SSL."

Next, please gather data on the command-line (as root):

cd /opt/kerio/mailserver
echo "thread apply all where" > foo
gdb ./mailserver ./core.#### -batch -x ./foo > threads.####.txt

Again, where #### is the number appended to the core file name.

Finally, gzip the core file:

gzip core.####

Please let me know when you have done this. After you do this, I will create an FTP account for you to upload the core file. Also, please ZIP together the lsof.txt and threads.####.txt files and send them to me as an attachment in reply to a ticket email from this support ticket.

Cut-and-paste for OSX
Please do the following while the problem is happening:

First, please enable "Connections" debug logging.  Right-click over the debug log, then choose "Set log events..." or "Messages..." then choose "Network Connections and SSL."

Next, please gather some data from the command line (as root):

lsof > lsof.txt  (Please send me the lsof.txt file)
kill -SEGV ####

Where #### is the PID of the mailserver process. This can be obtained using the "top" command or the "ps" command. The kill command will create a core file in /cores called core.#### where #### is the same number you killed up above.  Please notify me when you have this and I will create an FTP account to upload it to.

Finally, if it crashed, please send me the following file:
/Library/Logs/CrashReporter/mailserver.crash.log