-
Notifications
You must be signed in to change notification settings - Fork 59
[BUGS] Transport failure java.lang.IndexOutOfBoundsException: readerIndex(1) + length(1) #127
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
Comments
will you get the same error if you use https://github.com/andy-yx-chen/vertx-mysql-postgresql-client this instead? |
same error, how can I fix it? |
Can you share the updated stacktrace? |
the res.cause() of fail is the mysql field type is |
From the stacktrace it looks like you're still not using jasync-sql. Can you try to use that? |
can you please turn on trace logging on |
Looks like an impossible error, the okay message should never be one byte only, what’s the context for getting this error, what is the previous action you have done on the connection |
I have switched into The charset of my database is utf8mb4. Some values in my database are Null with |
My sense is the returned data was incorrectly parsed by the current driver and led to ok decoder is called |
Can you also please share the version of the mysql server? |
I use google cloud platform, the database version is MySQL 5.7. Sorry I didn't found the log on Here is my code: public Future<ResultSet> getResult(final String query) {
// Now do stuff with it:
// System.out.println("MYSQL:\t" + query);
Future<ResultSet> future = Future.future();
mySQLClient.getConnection(pool -> {
if (pool.succeeded()) {
SQLConnection connection = pool.result();
connection.query(query, res -> {
if (res.succeeded()) {
// Get the result set
future.complete(res.result());
} else {
// Failed!
future.fail(res.cause());
System.out.println(query);
System.out.println("get query result fail!");
}
connection.close();
});
} else {
System.out.println(pool.cause());
}
});
return future;
} For each query, I simply return a Future and use this code to handle their result Future<ResultSet> tag1Future = getResult(cmd1);
Future<ResultSet> tag2Future = getResult(cmd2);
// return future
Future<Double> tagScoreFuture = Future.future();
CompositeFuture.all(tag1Future, tag2Future).setHandler(resp -> {
if (resp.succeeded()) {
List<ResultSet> futureResult = resp.result().list();
String tag1 = futureResult.get(0).getResults().get(0).getString(0);
String tag2 = futureResult.get(1).getResults().get(0).getString(0); At the same time, there are hundreds of similar queries and Futures are created. I am worried that it is a concurrency problem. Now I think it is not a problem about NULL value, because I found some SQL statements will also fail even |
I don't think it is a concurrency-related issue. What I do suspect is that google cloud mysql send different ok messages on some cases. it looks like jdbc connector is more permissive in that manner: https://github.com/mysql/mysql-connector-j/blob/36534fa273b4d7824a8668ca685465cf8eaeadd9/src/main/protocol-impl/java/com/mysql/cj/protocol/x/StatementExecuteOkBuilder.java and allows not to send all required data. I think we can check the length of the message when creating OK message. @andy-yx-chen is there any specific reason you think this is a wrong message parsing? |
@oshai it looks like this message is attached to the other message, so I was suspecting if that is because the last frame was not correctly parsed and it mistakenly take the rest of buffer as an okay message. furthermore, if we can turn on the trace, then we will see what data we sent and receive to understand this issue a bit more |
@kashimotoxiang are you able to reproduce your issue towards an local MySQL server? or could you simplify your code to reproduce the issue and share with us |
Hello, Everyone:
There is a bug in your library:
DB: MySQL
SQL:
[iot_cloud]> SELECT iot_m_barrier.car_park_id FROM iot_m_barrier WHERE (iot_m_barrier.kid = 1576108104068099);
CREATE SQL:
car_park_id
varchar(64) NOT NULL DEFAULT '' COMMENT ' park ID ';EXPLAIN:
The type of field 'car_park_id' is varchar(64), use the default value '' will cause a IndexOutOfBoundsException, the stack trace like this:
14:03:37.527 [vert.x-eventloop-thread-0] ERROR com.github.mauricio.async.db.mysql.MySQLConnection - Transport failure
java.lang.IndexOutOfBoundsException: readerIndex(1) + length(1) exceeds writerIndex(1): UnpooledSlicedByteBuf(ridx: 1, widx: 1, cap: 1/1, unwrapped: UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeNoCleanerDirectByteBuf(ridx: 111, widx: 120, cap: 256))
at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1405) ~[netty-buffer-4.1.25.Final.jar:4.1.25.Final]
at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:707) ~[netty-buffer-4.1.25.Final.jar:4.1.25.Final]
at io.netty.buffer.AbstractByteBuf.readUnsignedByte(AbstractByteBuf.java:721) ~[netty-buffer-4.1.25.Final.jar:4.1.25.Final]
at io.netty.buffer.SwappedByteBuf.readUnsignedByte(SwappedByteBuf.java:536) ~[netty-buffer-4.1.25.Final.jar:4.1.25.Final]
at com.github.mauricio.async.db.util.ChannelWrapper$.readBinaryLength$extension(ChannelWrapper.scala:52) ~[db-async-common_2.12-0.2.21.jar:0.2.21]
at com.github.mauricio.async.db.mysql.decoder.OkDecoder.decode(OkDecoder.scala:29) ~[mysql-async_2.12-0.2.21.jar:0.2.21]
at com.github.mauricio.async.db.mysql.codec.MySQLFrameDecoder.doDecoding(MySQLFrameDecoder.scala:172) ~[mysql-async_2.12-0.2.21.jar:0.2.21]
at com.github.mauricio.async.db.mysql.codec.MySQLFrameDecoder.handleCommonFlow(MySQLFrameDecoder.scala:157) ~[mysql-async_2.12-0.2.21.jar:0.2.21]
at com.github.mauricio.async.db.mysql.codec.MySQLFrameDecoder.decode(MySQLFrameDecoder.scala:90) ~[mysql-async_2.12-0.2.21.jar:0.2.21]
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489) ~[netty-codec-4.1.25.Final.jar:4.1.25.Final]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428) ~[netty-codec-4.1.25.Final.jar:4.1.25.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265) ~[netty-codec-4.1.25.Final.jar:4.1.25.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.25.Final.jar:4.1.25.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.25.Final.jar:4.1.25.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.25.Final.jar:4.1.25.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [netty-transport-4.1.25.Final.jar:4.1.25.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.25.Final.jar:4.1.25.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.25.Final.jar:4.1.25.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [netty-transport-4.1.25.Final.jar:4.1.25.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.25.Final.jar:4.1.25.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:647) [netty-transport-4.1.25.Final.jar:4.1.25.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:582) [netty-transport-4.1.25.Final.jar:4.1.25.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:499) [netty-transport-4.1.25.Final.jar:4.1.25.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:461) [netty-transport-4.1.25.Final.jar:4.1.25.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884) [netty-common-4.1.25.Final.jar:4.1.25.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.25.Final.jar:4.1.25.Final]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]
The text was updated successfully, but these errors were encountered: