Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unchecked BufferUnderflowException propogates from DrizzleDriver.connect() #29

Open
TjlHope opened this issue Jun 12, 2014 · 0 comments

Comments

@TjlHope
Copy link

TjlHope commented Jun 12, 2014

I've had a BufferUnderflowException kill a DB Thread in a high performance application, with the following stack trace ('Caused by:' because this is after an explicit catch and log in the application):

Caused by: java.nio.BufferUnderflowException
      at java.nio.Buffer.nextGetIndex(Buffer.java:497)
      at java.nio.HeapByteBuffer.getInt(HeapByteBuffer.java:355)
      at org.drizzle.jdbc.internal.common.packet.buffer.Reader.readInt(Reader.java:86)
      at org.drizzle.jdbc.internal.mysql.packet.MySQLGreetingReadPacket.<init>(MySQLGreetingReadPacket.java:39)
      at org.drizzle.jdbc.internal.mysql.MySQLProtocol.<init>(MySQLProtocol.java:153)
      at org.drizzle.jdbc.DrizzleDriver.connect(DrizzleDriver.java:73 

This was caused by MySQL blocking the host.

I'm guessing that the easiest way to solve it would be to catch the BufferUnderflowException at some point (Reader?) and re-throw it wraped in an IOException (so that that gets wrapped in a QueryException in MySQLProtocol).

But, that first packet isn't required to be a MySQLGreetingReadPacket:

It starts with the client connect()ing to the server which may send a ERR packet and finish the handshake or send a Initial Handshake Packet which the client answers with a Handshake Response Packet

So a proper fix would presumably require determining the type of packet first, and acting accordingly in the MySQLProtocol constructor.

@TjlHope TjlHope changed the title Unchecked BufferowException propogates from DrizzleDriver.connect() Unchecked BufferUnderflowException propogates from DrizzleDriver.connect() Jun 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant