Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Os x terminal, ssh , and too many open files

I have some code that runs several rest queries over a connection that is ssh forwarded to an AWS machine (fyi: these queries are hitting a Solr server running on this machine), and the queries run against my localhost (which is forwarded to the AWS instance).

The code initially runs great getting data as necessary, but after running for a while, the code stalls (in eclipse).

At this exact moment, the terminal (i.e. where I have started my ssh tunnel) goes completely frozen, filling up with the String :

"accept : too many open files"

Because this infinite print is not associated with a bash terminal (i.e. I can't tell wether the ssh connection is still alive or not, and there is no text indicating which shell im in... just unpridled, relentless print statements) I cant tell wether it's coming from amazon, or from my client terminal.

I want to find the cause of this behavior and pinpoint the machine which is causing my terminal to explode

To test which of the two machines was causing the infinite print outs of the error, I ran the ulimit command on the server... and found that the max number of open files allowed (on the aws server) was well above the amount of open files (also determined using ulimit) at any given time while the client program (running from my ide) is executing.

I did the same test on my client , and found no significant increase in the number of open files.

Some side details : I'm running several hundreds of queries into a SOLR server that has over 100GB of data in a short time period.

Any hints on how to determine why my sshd mac os x terminal is dying and infinitely printing this message would be potentially very useful to me. Of course, wether or not they were specific to solr. That said, any insights into why this would happen when using a solr service may also help to solve this problem.

like image 416
jayunit100 Avatar asked Apr 10 '12 20:04

jayunit100


People also ask

How do I fix too many open files on my Mac?

A simple fix for the "too many files open" limitation of Mac OS is to use the "ulimit - n" command. Curiously, the value of n appears to be critical to whether or not this command is accepted by MacOS. I've found that ulimit -n 10240 (the default is 256) works but n values higher do not.

How do I fix too many open files?

If the number of open files has exceeded the hard limit, the user won't be able to open new files until the previously opened ones are closed. To view the current limits, use the ulimit command with the -S (soft) or -H (hard) option and the -n (the maximum number of open file descriptors) option.

How do I stop SSH on Mac?

To disconnect from the server and close the SSH connection, simply type "exit" and press the Enter key. This will disconnect you from the remote server and return you to your local machine's command line. 7.

How can I prevent an ssh session from hanging in OS X terminal?

For killing it when it gets hang up, you can use the ssh escape character: ~. That is, press the tilde and then the period, if it doesn't work, press Enter before you press that, that will kill the connection immediately. The "ssh escape character" tip is wonderful!!


1 Answers

You could try looking at ulimit (via Terminal type):

ulimit -a

Specifically, check the value for open files. On my machine (OS X) it reports 256. You might want to try increasing it to 512:

ulimit -n 512
like image 187
nickdos Avatar answered Sep 19 '22 03:09

nickdos