Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Sleeping mysql connections after finish and disconnect

by fishmonger (Chaplain)
on Sep 15, 2015 at 20:32 UTC ( [id://1142129]=note: print w/replies, xml ) Need Help??


in reply to Sleeping mysql connections after finish and disconnect

What is the interactive_timeout set to? Have you tried lowering it? I'd lower both of the timeouts to a more reasonable level.

Do you have the slow query log enabled?

Are most of the sleeping connections from the same host?

  • Comment on Re: Sleeping mysql connections after finish and disconnect

Replies are listed 'Best First'.
Re^2: Sleeping mysql connections after finish and disconnect
by drusher (Initiate) on Sep 18, 2015 at 15:59 UTC
    We have slow queries log enabled and Icinga monitoring the server.

    The precipitating issue is that we have a table that has too much data for InnoDB so it is MyISAM, which is real slow in a multiuser environment due to table locking

    Peak server usage is fairly consistent from day to day, but the problem comes and goes without an explanation. For now I moved some records to history so we have about 29k records instead of 38k records in the MyISAM table.

    We have a couple of hosts making calls, but the majority of the hanging queries come from one application that makes queries to a big table.

    This does not explain why we have queries against this one big MyISAM table that are apparently HUNG and run for hours. This does not make sense when all queries are finished and dbconnects always done. I think that when perl signals the disconnect, MySQL / ISAM does not always get the signal to close the connection. It looks like the connection is sitting there doing nothing while tying up resources. There was a PHP bug similar to this -- so I am wondering if Perl has the same bug??

    We are playing with wait_timeout in development. So far 600 works without killing crons that take a while to run. Obviously this is the only possible fallback fix.

    Now that InnoDB is launched and working, we are hoping that the MySQL team will burp the InnoDB max data size up to 384k (or the same as MyISAM whatever that is). InnoDB should work for any existing MyISAM table. Unless there is some reason above my pay scale, it does not make sense that row locking would require a smaller data size. Table locking is a method (in my book) and is not a particularly wise method in the majority of systems which are mult-user.

      Could be one or more of related bottlenecks:

      Do you have optimized statistics for the table?

      are you using transactions?do you exclusively lock the whole table or do do use page level locking?
      If you lock the whole table exclusively for each transaction you do have a big issue.
      There is also possibility that transactions within a session are getting hung and being zombied but not the session itself

      ISAM tables are notorious for overflow pages,better try a btree structure

      Are your queries using the indexes? are you using functions in the where clause?

      what is the query execution plan's estimation on Disk I/O resources for the given queries?

      This post suggests sleeping connections are not always a problem.

      This does not explain why we have queries against this one big MyISAM table that are apparently HUNG and run for hours.

      Have you looked at the output from EXPLAIN

      poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1142129]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found