Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Check the <code>ulimit</code> and <code>quota</code> for the box and the user running the scripts. <code>/etc/security/limits.conf</code> may also contain resource restrictions that you might want to modify. </p> <p><code>ulimit -n</code> will show the max number of open file descriptors allowed.</p> <ul> <li>Might this have been exceeded with all of the open sockets?</li> <li>Is the script closing each sockets when it's done with it?</li> </ul> <p>You can also check the fd's with <code>ls -l /proc/[PID]/fd/</code> where <code>[PID]</code> is the process id of one of the scripts.</p> <p><em>Would need to see some code to tell what's really going on..</em></p> <hr> <p><strong>Edit</strong> (<em>Importing comments and more troubleshooting ideas</em>):</p> <p>Can you show the code where your <em>opening</em> and <em>closing</em> the connections?<br />When just run a few script processes are running, do they too start to go idle after a while? Or is it only when there are several hundred+ running at once that this happens?<br />Is there a single parent process that starts all of these scripts?</p> <p>If your using <code>s = urllib2.urlopen(someURL)</code>, make sure to <code>s.close()</code> when your done with it. Python can <em>often</em> close things down for you (like if your doing <code>x = urllib2.urlopen(someURL).read()</code>), but it will leave that to <strong>you</strong> if you if told to (such as assigning a variable to the return value of <code>.urlopen()</code>). Double check your opening and closing of urllib calls (or <em>all</em> I/O code to be safe). If each script is designed to only have 1 open socket at a time, and your <code>/proc/PID/fd</code> is showing multiple active/open sockets per script process, then there is definitely a <em>code</em> issue to fix.</p> <p><code>ulimit -n</code> showing <code>1024</code> is giving the <strong>limit</strong> of open <strong>socket/fd's</strong> that the <em>mysql</em> user can have, you can change this with <code>ulimit -S -n [LIMIT_#]</code> but check out this article first: <br /><a href="http://blogs.oracle.com/rainy/entry/changing_process_max_file_descriptor" rel="nofollow">Changing process.max-file-descriptor using 'ulimit -n' can cause MySQL to change table_open_cache value</a>.</p> <p>You may need to log out and shell back in after. And/Or add it to <code>/etc/bashrc</code> (don't forget to <code>source /etc/bashrc</code> if you change <code>bashrc</code> and don't want to log out/in).</p> <p><strong>Disk space</strong> is another thing that I have found out (the hard way) can cause very weird issues. I have had processes act like they are running (not zombied) but not doing what is expected because they had open handles to a log file on a partition with zero disk space left.</p> <p><code>netstat -anpTee | grep -i mysql</code> will also show if these sockets are connected/established/waiting to be closed/waiting on timeout/etc.</p> <p><strong><code>watch -n 0.1 'netstat -anpTee | grep -i mysql'</code></strong> to see the sockets open/close/change state/etc in <em>real time</em> in a nice table output (may need to <code>export GREP_OPTIONS=</code> first if you have it set to something like <code>--color=always</code>).</p> <p><code>lsof -u mysql</code> or <code>lsof -U</code> will also show you open FD's (the output is quite verbose).</p> <hr> <pre><code>import urllib2 import socket socket.settimeout(15) # or settimeout(0) for non-blocking: #In non-blocking mode (blocking is the default), if a recv() call # doesn’t find any data, or if a send() call can’t # immediately dispose of the data, # a error exception is raised. #...... try: s = urllib2.urlopen(some_url) # do stuff with s like s.read(), s.headers, etc.. except (HTTPError, etcError): # myLogger.exception("Error opening: %s!", some_url) finally: try: s.close() # del s - although, I don't know if deleting s will help things any. except: pass </code></pre> <hr> <p><strong>Some man pages and reference links:</strong></p> <blockquote> <ul> <li><a href="http://compute.cnr.berkeley.edu/cgi-bin/man-cgi?ulimit" rel="nofollow">ulimit</a></li> <li><a href="http://compute.cnr.berkeley.edu/cgi-bin/man-cgi?quota" rel="nofollow">quota</a></li> <li><a href="http://ss64.com/bash/limits.conf.html" rel="nofollow">limits.conf</a></li> <li><a href="http://en.wikipedia.org/wiki/Fork_bomb" rel="nofollow">fork bomb</a></li> <li><a href="http://blogs.oracle.com/rainy/entry/changing_process_max_file_descriptor" rel="nofollow">Changing process.max-file-descriptor using 'ulimit -n' can cause MySQL to change table_open_cache value</a></li> <li><a href="http://docs.python.org/library/socket.html" rel="nofollow">python <em>socket</em> module</a></li> <li><a href="http://linux.die.net/man/8/lsof" rel="nofollow">lsof</a></li> </ul> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload