question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MSSQL query throws io.netty.handler.codec.DecoderException caused by IndexOutOfBoundsException

See original GitHub issue

Version

4.1.3

Context

Using MSSQL, the following query:

select table_name as TABLE_NAME, column_name as COLUMN_NAME, data_type as TYPE_NAME, null as COLUMN_SIZE, 
             null as DECIMAL_DIGITS, is_nullable as IS_NULLABLE, null as DATA_TYPE 
from information_schema.columns 
order by table_catalog, table_schema, table_name, column_name, ordinal_position

throws:

io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 8, length: 4088 (expected: range(0, 53))

Full stacktrace is below.

The following query fails intermittently with the same exception:

select convert( nvarchar(128), table_name ) as TABLE_NAME, convert( nvarchar(128), column_name ) as COLUMN_NAME,
         convert( nvarchar(128), data_type ) as TYPE_NAME, null as COLUMN_SIZE, null as DECIMAL_DIGITS, 
         convert( varchar(3), is_nullable ) as IS_NULLABLE, null as DATA_TYPE 
from information_schema.columns 
order by table_catalog, table_schema, table_name, column_name, ordinal_position

The following query succeeds:

select table_name as TABLE_NAME, column_name as COLUMN_NAME, data_type as TYPE_NAME, null as COLUMN_SIZE,
             is_nullable as IS_NULLABLE
from information_schema.columns
order by table_catalog, table_schema, table_name, column_name, ordinal_position

Do you have a reproducer?

Yes, but it is fairly complicated involving Hibernate ORM and Reactive PRs: ORM: https://github.com/hibernate/hibernate-orm/pull/4177 Reactive: https://github.com/hibernate/hibernate-reactive/pull/945

It would probably be easier to add a test to MSSQLQueriesTest. I’m having trouble getting tests to run locally. I’ll see if I can get that working tomorrow.

Steps to reproduce

Extra

  • Fedora
  • JDK 1.8

Full stacktrace:

java.util.concurrent.CompletionException: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 8, length: 4088 (expected: range(0, 53))
	at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292) ~[?:1.8.0_172-ea]
	at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308) ~[?:1.8.0_172-ea]
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:593) ~[?:1.8.0_172-ea]
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577) ~[?:1.8.0_172-ea]
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474) ~[?:1.8.0_172-ea]
	at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977) ~[?:1.8.0_172-ea]
	at io.vertx.core.Future.lambda$toCompletionStage$2(Future.java:362) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureImpl$3.onFailure(FutureImpl.java:153) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.tryFail(PromiseImpl.java:23) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.sqlclient.impl.QueryResultBuilder.tryFail(QueryResultBuilder.java:118) ~[vertx-sql-client-4.1.3.jar:4.1.3]
	at io.vertx.core.Promise.fail(Promise.java:89) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.Promise.handle(Promise.java:53) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.Promise.handle(Promise.java:29) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureImpl$3.onFailure(FutureImpl.java:153) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.tryFail(PromiseImpl.java:23) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.onFailure(PromiseImpl.java:54) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureImpl$ListenerArray.onFailure(FutureImpl.java:268) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.tryFail(PromiseImpl.java:23) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.onFailure(PromiseImpl.java:54) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.handle(PromiseImpl.java:43) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.future.PromiseImpl.handle(PromiseImpl.java:23) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.sqlclient.impl.command.CommandResponse.fire(CommandResponse.java:46) ~[vertx-sql-client-4.1.3.jar:4.1.3]
	at io.vertx.sqlclient.impl.SocketConnectionBase.handleMessage(SocketConnectionBase.java:279) ~[vertx-sql-client-4.1.3.jar:4.1.3]
	at io.vertx.sqlclient.impl.SocketConnectionBase.lambda$init$0(SocketConnectionBase.java:98) ~[vertx-sql-client-4.1.3.jar:4.1.3]
	at io.vertx.core.net.impl.NetSocketImpl.lambda$new$1(NetSocketImpl.java:97) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.streams.impl.InboundBuffer.handleEvent(InboundBuffer.java:240) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.streams.impl.InboundBuffer.write(InboundBuffer.java:130) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.net.impl.NetSocketImpl.lambda$handleMessage$9(NetSocketImpl.java:390) ~[vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:50) [vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.ContextImpl.emit(ContextImpl.java:274) [vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:22) [vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.net.impl.NetSocketImpl.handleMessage(NetSocketImpl.java:389) [vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.net.impl.ConnectionBase.read(ConnectionBase.java:155) [vertx-core-4.1.3.jar:4.1.3]
	at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:154) [vertx-core-4.1.3.jar:4.1.3]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.vertx.mssqlclient.impl.codec.TdsMessageCodec.fail(TdsMessageCodec.java:58) [vertx-mssql-client-4.1.3.jar:4.1.3]
	at io.vertx.mssqlclient.impl.codec.TdsMessageCodec.exceptionCaught(TdsMessageCodec.java:48) [vertx-mssql-client-4.1.3.jar:4.1.3]
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:281) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:273) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:143) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:381) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) [netty-transport-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) [netty-common-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.67.Final.jar:4.1.67.Final]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172-ea]
Caused by: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 8, length: 4088 (expected: range(0, 53))
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:477) ~[netty-codec-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) ~[netty-codec-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.67.Final.jar:4.1.67.Final]
	... 15 more
Caused by: java.lang.IndexOutOfBoundsException: index: 8, length: 4088 (expected: range(0, 53))
	at io.netty.buffer.AbstractByteBuf.checkRangeBounds(AbstractByteBuf.java:1390) ~[netty-buffer-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.buffer.AbstractByteBuf.checkIndex0(AbstractByteBuf.java:1397) ~[netty-buffer-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.buffer.PooledSlicedByteBuf.slice(PooledSlicedByteBuf.java:106) ~[netty-buffer-4.1.67.Final.jar:4.1.67.Final]
	at io.vertx.mssqlclient.impl.codec.TdsPacketDecoder.decode(TdsPacketDecoder.java:38) ~[vertx-mssql-client-4.1.3.jar:4.1.3]
	at io.vertx.mssqlclient.impl.codec.TdsPacketDecoder.decode(TdsPacketDecoder.java:21) ~[vertx-mssql-client-4.1.3.jar:4.1.3]
	at io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:332) ~[netty-codec-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:507) ~[netty-codec-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:446) ~[netty-codec-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) ~[netty-codec-4.1.67.Final.jar:4.1.67.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.67.Final.jar:4.1.67.Final]
	... 15 more

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tsegismontcommented, Sep 3, 2021

Closed in e4a543e

1reaction
tsegismontcommented, Sep 3, 2021

@gbadner I was able to reproduce:

  @Test
  public void testIndexOutOfBoundsException(TestContext ctx) {
    connection.preparedQuery("select table_name as TABLE_NAME, column_name as COLUMN_NAME, data_type as TYPE_NAME, null as COLUMN_SIZE, \n" +
        "             null as DECIMAL_DIGITS, is_nullable as IS_NULLABLE, null as DATA_TYPE \n" +
        "from information_schema.columns \n" +
        "order by table_catalog, table_schema, table_name, column_name, ordinal_position")
      .execute(Tuple.tuple(), ctx.asyncAssertSuccess(rows -> {
        ctx.verify(unused -> {
          for (Row row : rows) {
            System.out.println("row = " + row.toJson());
          }
        });
      }));
  }

Thanks again for the report

Read more comments on GitHub >

github_iconTop Results From Across the Web

My netty server reported an error 'io.netty.handler.codec ...
netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 16384, length: -14771 (expected: range(0, 8192))'.
Read more >
java - Netty decoder throws IndexOutOfBounsException while ...
The problem here is caused by how the data is sent over the network. The data received by ByteToMessageDecoder is not guaranteed to...
Read more >
ATERNOS io.netty.handler.DecoderException: java ... - YouTube
Internal Exception: io. netty. handler. DecoderException : java.lang. IndeXOutOfBoundsException : Index: 25, Size: 5Hey guys I am xRadarr, ...
Read more >
Exception when you execute a query - SQL Server
Cause. This issue occurs because SSMS has insufficient memory to allocate for large results. Note. SSMS is a 32-bit process.
Read more >
[1.16.1] Internal Exception: io.netty.handler.codec ...
1] Internal Exception: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(23) + length(8) exceeds ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found