Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread hangs when connecting to database

 
Martin Wingert
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have an issue with threads locked while waiting for a response from a database server running MySQL.

I have an application using Proxool managing a connection pool to a MySQL database. The application and the database are on separate servers. With a random frequency thread hangs waiting for a response from the database server. This causes other threads to hang waiting for the same lock.

Since it is during a get connection request it can't be any long query it is waiting for. I have thought of two possible reasons myself:
1. network related - ie some lag in the network connection between the application server and the database server. But this shouldn't be the case since when this happened the connection between the servers was verified.

2. database busy - and not being able to process a get connection. I don't know if this is possible.

Does anyone have any good suggestions on what could cause this or on how to proceed with the investigation?

Versions of MySQL and Proxool:
------------------------------
MySQL-server-community-5.0.81
MySQL connector 5.1.6
Proxool 0.9.1


Thread dumps from the JVM:
--------------------------
Thread waiting for a response from the MySQL server holding lock <0x00002b7a156bfdf8>:

"RequestProcessor-8" daemon prio=1 tid=0x000000004d30bdb0 nid=0x729c runnable [0x00000000429cb000..0x00000000429ccd90]
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
- locked <0x00002b7a81a24730> (a com.mysql.jdbc.util.ReadAheadInputStream)
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2428)
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:590)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1069)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031)
- locked <0x00002b7a81a1f008> (a java.lang.Object)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:298)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
at java.sql.DriverManager.getConnection(Unknown Source)
- locked <0x00002b7a156bfdf8> (a java.lang.Class)
at java.sql.DriverManager.getConnection(Unknown Source)
- locked <0x00002b7a156bfdf8> (a java.lang.Class)
at org.logicalcobwebs.proxool.DefaultConnectionBuilder.buildConnection(DefaultConnectionBuilder.java:39)
at org.logicalcobwebs.proxool.Prototyper.buildConnection(Prototyper.java:159)
at org.logicalcobwebs.proxool.ConnectionPool.getConnection(ConnectionPool.java:211)
at org.logicalcobwebs.proxool.ProxoolDriver.connect(ProxoolDriver.java:89)
at java.sql.DriverManager.getConnection(Unknown Source)
- locked <0x00002b7a156bfdf8> (a java.lang.Class)
at java.sql.DriverManager.getConnection(Unknown Source)
- locked <0x00002b7a156bfdf8> (a java.lang.Class)


Threads waiting for the lock <0x00002b7a156bfdf8>:

"/reports_processor(ControlledThread)" daemon prio=1 tid=0x00002aaab866b020 nid=0x731e waiting for monitor entry [0x000000004a94b000..0x000000004a94be10]
at java.sql.DriverManager.getConnection(Unknown Source)
- waiting to lock <0x00002b7a156bfdf8> (a java.lang.Class)
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your MySQL server is not local there might just be a huge latency for requests.

You could try to simply create a connection and run simple queries to see how long that takes.

By the way, if you like Proxool you might want to check out JDBCSupport. It offers pooling and other handy features for database interaction. If you decide to play around with it a quick review would be awesome :-)...
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you think this might be a problem with the DB serving out connections, an easy way to check it would be to write a small program that asks for a lot of connections and releases them after a long time. If a call for getting the connection hangs, you know where the trouble is
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic