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

Lettuce doesn't handle deleted stream items (NullPointerException) #1474

Closed
chemist777 opened this issue Oct 26, 2020 · 1 comment
Closed
Labels
type: bug A general bug
Milestone

Comments

@chemist777
Copy link

chemist777 commented Oct 26, 2020

Bug Report

When I try to read pending messages via XREADGROUP I get the following NullPointerException.

It occurs when a pending message is already deleted from the stream due to its size limit.

The issue is related to the Redis behavior described in this comment https://github.com/redis/redis/blob/5.0.2/src/t_stream.c#L1031.

Also, Python client faced the same issue the previous year redis/redis-py#1116

Current Behavior

Stack trace
java.lang.NullPointerException: null
	at io.lettuce.core.codec.ByteArrayCodec.getBytes(ByteArrayCodec.java:84)
	at io.lettuce.core.codec.ByteArrayCodec.decodeKey(ByteArrayCodec.java:59)
	at io.lettuce.core.codec.ByteArrayCodec.decodeKey(ByteArrayCodec.java:28)
	at io.lettuce.core.output.StreamReadOutput.set(StreamReadOutput.java:73)
	at io.lettuce.core.protocol.RedisStateMachine.safeSet(RedisStateMachine.java:810)
	at io.lettuce.core.protocol.RedisStateMachine.handleNull(RedisStateMachine.java:392)
	at io.lettuce.core.protocol.RedisStateMachine$State$Type.handle(RedisStateMachine.java:206)
	at io.lettuce.core.protocol.RedisStateMachine.doDecode(RedisStateMachine.java:334)
	at io.lettuce.core.protocol.RedisStateMachine.decode(RedisStateMachine.java:295)
	at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:799)
	at io.lettuce.core.protocol.CommandHandler.decode0(CommandHandler.java:750)
	at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:733)
	at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:618)
	at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:560)
	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:714)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	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:834)

Expected behavior/code

No NPE.

Environment

  • Lettuce version(s): 6.0.0.RELEASE
  • Redis version: 6.0.8

Also, I use ByteArrayCodec for keys & values.

@chemist777 chemist777 added the type: bug A general bug label Oct 26, 2020
@chemist777 chemist777 changed the title Lettuce doesn't handle expired stream items (NullPointerException) Lettuce doesn't handle deleted stream items (NullPointerException) Oct 26, 2020
@mp911de mp911de added this to the 5.3.5 milestone Oct 26, 2020
mp911de added a commit that referenced this issue Oct 26, 2020
We now correctly decode stream messages that are deleted (i.e. don't return the body).
mp911de added a commit that referenced this issue Oct 26, 2020
We now correctly decode stream messages that are deleted (i.e. don't return the body).
mp911de added a commit that referenced this issue Oct 26, 2020
We now correctly decode stream messages that are deleted (i.e. don't return the body).
@mp911de
Copy link
Collaborator

mp911de commented Oct 26, 2020

Thanks a lot for letting us know. That's fixed and backported now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants