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.

IndexOutOfBoundsException on reading PENDING Array[Byte] message

See original GitHub issue

Expected behavior Possibly a null for a message value could be returned instead of an exception.

Actual behavior

An exception is thrown

[ERROR][o.r.c.h.CommandDecoder][redisson-netty-2-15] - Unable to decode data. channel: [id: 0xa009e266, L:/127.0.0.1:60975 - R:localhost/127.0.0.1:7379], reply: ReplayingDecoderByteBuf(ridx=66, widx=97), command: (XREADGROUP), promise: RedissonPromise [promise=ImmediateEventExecutor$ImmediatePromise@39d142a8(incomplete)], params: [GROUP, my-stream-group, my-consumer, COUNT, 10, BLOCK, 10000, STREAMS, my-stream, 0]
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
	at java.base/java.util.Objects.checkIndex(Objects.java:372)
	at java.base/java.util.ArrayList.get(ArrayList.java:459)
	at org.redisson.client.protocol.decoder.StreamObjectMapReplayDecoder.decode(StreamObjectMapReplayDecoder.java:46)
	at org.redisson.client.protocol.decoder.StreamObjectMapReplayDecoder.decode(StreamObjectMapReplayDecoder.java:32)
	at org.redisson.client.protocol.decoder.MapEntriesDecoder.decode(MapEntriesDecoder.java:50)
	at org.redisson.client.protocol.decoder.ListMultiDecoder2.decode(ListMultiDecoder2.java:47)
	at org.redisson.client.handler.CommandDecoder.decodeList(CommandDecoder.java:436)
	at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:392)
	at org.redisson.client.handler.CommandDecoder.decodeList(CommandDecoder.java:427)
	at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:392)
	at org.redisson.client.handler.CommandDecoder.decodeList(CommandDecoder.java:427)
	at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:392)
	at org.redisson.client.handler.CommandDecoder.decodeList(CommandDecoder.java:427)
	at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:392)
	at org.redisson.client.handler.CommandDecoder.decodeList(CommandDecoder.java:427)
	at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:392)
	at org.redisson.client.handler.CommandDecoder.decodeCommand(CommandDecoder.java:198)
	at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:137)
	at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:113)
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:507)
	at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:366)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1372)
	at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1235)
	at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1284)
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:507)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:446)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)

Steps to reproduce or test case

  1. I had a steam consumer that had both new and PENDING messages.
  2. Then I cleaned up my stream from the old messages using XTRIM my-stream MINID 1633844273000-0 command. All the events up to this point have been removed.

It happened that some of the PENDING messages were also removed by XTRIM command. Still, they are present in PENDING list of my consumer, but the values of the messages are nil.

>> XREADGROUP GROUP my-stream-group my-consumer COUNT 10 BLOCK 1000 STREAMS my-stream 0

1) 1) "my-stream"
   2) 1) 1) "1632735948072-0"
         2) (nil)
      2) 1) "1632735948188-0"
         2) (nil)

When I try to look for data for one of those nil events (1632735948072-0), I do not find them, but Redis is providing me newer message:

>> XREAD COUNT 1 BLOCK 1000 STREAMS my-stream 1632735948072-0

1) 1) "my-stream"
   2) 1) 1) "1633931405049-0"
         2) 1) "schema"
            2) "\nS\n$f69b9f8f-2998-4f99-806d-978150a20af0\x12$4d39171e-f7ea-48b3-a1de-bf2e48fff674\x18\xbd\xcd\x9a\xef\xc6/\x12Bk-ff4f6d70f50e747bd1ece8002ee8ed0344f59b6243e0d70d76fb912701de27c2\x1aBk-da8e85720f18335ccf72a11e955ea97d5456ca0630472a6f2f50dd9a968ea44e"

I understand this looks like Redis bug and PENDING should not reference the message that no longer exists. But I think Redisson could handle better this case and return at least null as a message value instead of throwing an exception. The reason is, I am reading 10 messages and only 1 of them can be problematic, while now the whole XREADGROUP command blows, and I am unable to handle that problematic message programmatically, e.g. acknowledge this message as having wrong message value.

Redis version 6.2.5

Redisson version 3.16.3

Redisson configuration

new Config().setCodec(ByteArrayCodec.INSTANCE)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mrnikocommented, Oct 15, 2021

it returns message, but without any data.

1reaction
mrnikocommented, Oct 15, 2021

Fixed! Thanks for report

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - IndexOutOfBoundsException When read and write from ...
It looks like you're just trying to read from the input stream and write it to the output stream ... while ((bytesRead =...
Read more >
Example usage for java.lang IndexOutOfBoundsException ...
Returns the detail message string of this throwable. ... catch (IOException e) { log.warn(String.format("Cannot read symbolic link target of %s:%s", this.
Read more >
IndexOutOfBoundsException on byte array parsing · Issue #254
In FlatBuffer format. It cannot read JSON directly.
Read more >
reading from a byte array threw an ioexception (should never ...
ProtobufException: Protocol message contained an inval 博客分类: java 异常 log4j:WARN No appenders could be found for logger (org.springframework.core.env.
Read more >
Diff - e237f9d^! - platform/frameworks/opt/telephony - Google Git
This - * broadcast is intended for apps that—while not selected as the default SMS app—need to - * read special incoming messages...
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