Flipkart / phantom-mysql-proxy

The Mysql proxy leverages the Phantom extensibility support.
22 stars 8 forks source link

Exception/Closed MySQL connections on every request #1

Closed hexuallyactive closed 10 years ago

hexuallyactive commented 10 years ago

Hi, whenever I run a query against mysql via the proxy, the connection gets closed and the proxy server logs:

01:31:39.123 [New I/O server worker #1-1] WARN c.f.p.r.i.s.n.h.m.MysqlChannelHandler - Exception [id: 0x0af69121, /127.0.0.1:59273 => /127.0.0.1:8080] EXCEPTION: java.net.SocketException: Socket closed thrown on Channel [id: 0x0af69121, /127.0.0.1:59273 => /127.0.0.1:8080]. Disconnect initiated Aug 27, 2014 1:31:39 AM org.jboss.netty.channel.SimpleChannelHandler WARNING: EXCEPTION, please implement com.flipkart.phantom.runtime.impl.server.netty.handler.mysql.MysqlChannelHandler.exceptionCaught() for proper handling. java.net.SocketException: Socket closed at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:121) at java.net.SocketOutputStream.write(SocketOutputStream.java:147) at com.github.mpjct.jmpjct.mysql.proto.Packet.write(Unknown Source) at com.flipkart.phantom.runtime.impl.server.netty.handler.mysql.MysqlChannelHandler.executeQueries(MysqlChannelHandler.java:333) at com.flipkart.phantom.runtime.impl.server.netty.handler.mysql.MysqlChannelHandler.handleQueries(MysqlChannelHandler.java:316) at com.flipkart.phantom.runtime.impl.server.netty.handler.mysql.MysqlChannelHandler.messageReceived(MysqlChannelHandler.java:180) at com.flipkart.phantom.runtime.impl.server.netty.handler.mysql.MysqlChannelHandler.handleUpstream(MysqlChannelHandler.java:170) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:327) at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:305) at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:207) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:343) at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:274) at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:194) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744)

regunathb commented 10 years ago

Kurt,

Sharing these details will help us debug the issue:

  1. Version of proxy you are using (or) is it built from github master.
  2. Do you have a sample test case/class alongwith required table schema that we can use to reproduce the problem?
  3. Need to see file contents of : spring-proxy-listener-config.xml and spring-proxy-handler-config.xml from your proxy configuration.

Regards Regu

On Wed, Aug 27, 2014 at 7:17 AM, Kurt Ward notifications@github.com wrote:

Hi, whenever I run a query against mysql via the proxy, the connection gets closed and the proxy server logs:

01:31:39.123 [New I/O server worker #1 https://github.com/Flipkart/phantom-mysql-proxy/issues/1-1] WARN c.f.p.r.i.s.n.h.m.MysqlChannelHandler - Exception [id: 0x0af69121, / 127.0.0.1:59273 => /127.0.0.1:8080] EXCEPTION: java.net.SocketException: Socket closed thrown on Channel [id: 0x0af69121, /127.0.0.1:59273 => / 127.0.0.1:8080]. Disconnect initiated Aug 27, 2014 1:31:39 AM org.jboss.netty.channel.SimpleChannelHandler WARNING: EXCEPTION, please implement com.flipkart.phantom.runtime.impl.server.netty.handler.mysql.MysqlChannelHandler.exceptionCaught() for proper handling. java.net.SocketException: Socket closed at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:121) at java.net.SocketOutputStream.write(SocketOutputStream.java:147) at com.github.mpjct.jmpjct.mysql.proto.Packet.write(Unknown Source) at com.flipkart.phantom.runtime.impl.server.netty.handler.mysql.MysqlChannelHandler.executeQueries(MysqlChannelHandler.java:333) at com.flipkart.phantom.runtime.impl.server.netty.handler.mysql.MysqlChannelHandler.handleQueries(MysqlChannelHandler.java:316) at com.flipkart.phantom.runtime.impl.server.netty.handler.mysql.MysqlChannelHandler.messageReceived(MysqlChannelHandler.java:180) at com.flipkart.phantom.runtime.impl.server.netty.handler.mysql.MysqlChannelHandler.handleUpstream(MysqlChannelHandler.java:170) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:327) at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:305) at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:207) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:343) at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:274) at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:194) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744)

— Reply to this email directly or view it on GitHub https://github.com/Flipkart/phantom-mysql-proxy/issues/1.

hexuallyactive commented 10 years ago

Hi Regu,

I am using github master. MySQL version is 5.5.37. I am using the default spring-proxy-listener-config.xml and spring-proxy-handler-config.xml I don't have a test case readily available, but simply trying to use MySQL Workbench to connect to the proxy yields an exception. I'll try to look into it further, but any info you might have certainly would help.

Thanks! Kurt

kormoc commented 10 years ago

What version of mysql workbench? Which OS?

hexuallyactive commented 10 years ago

Hi Rob!

mysql workbench 6.1 on OS X. I get a one exception using workbench, and a different exception when using the mysql cli from localhost (on the server, which is Ubuntu 12.04). Let me know if there is anything else I can supply that might help.

Kurt

kormoc commented 10 years ago

What version of MySQL and which fork (MySQL/MariaDB/etc)?

hexuallyactive commented 10 years ago

I'm using MySQL 5.5.37. On a side note - I have also tried using jmpjct (master) as well as a proxy, and cannot seem to make it work either (although it did some time back). I'll investigate older server versions, etc. and see if I can find a working version - maybe that will help us.

samaitra commented 10 years ago

Hi Kurt,

I am able to reproduce this issue when I am using mysql password. I have not faced this issue earlier but able to reproduce it in mysql version 5.6.19.

Can you try replacing your jdbc url to something like below.
jdbc:mysql://localhost:8080/?characterEncoding=utf8&user=root&password=

I tried with above jdbc url and the issue went away. I will investigate further and fix the issue.

Regards Saikat

samaitra commented 10 years ago

Hello Kurt,

I was testing this issue using unit tests which uses jdbc url and replied in that context above. I am able to reproduce the issue using Mysql workbench 6.1 when using valid user with password credentials.

The issue do not surface with user root and blank password.

I am investigating it further.

Saikat

samaitra commented 10 years ago

Fixed.:)