Initially reported to the google group: https://groups.google.com/forum/?#!msg/redis-db/kzsMvOE_n5Q/S1U6FVdAAgAJ

Consider the following scenario: you have a stream and you delete the most recent entry. Then before a new entry is added you call XREAD BLOCK with the new most recent stream id, ie what was the penultimate stream id before. The documented behavior is to block until either a message is added or the block duration times out. However, we consistently observe that redis will immediately return an empty list. We observed this on 5.0.6 and 5.0.9 and it seems to be fixed in 6. A fix seems to have been merged into 5.0 RC5 (eea0d3c5) but it does not seem to be in master: https://github.com/antirez/redis/blob/unstable/src/t_stream.c#L1543.

We have replicated it with the following (run on 5.0.9):

> XADD a_stream * foo bar
"1590977447146-0"
> XADD a_stream * baz bloop
"1590977479145-0"
> XREAD BLOCK 10000 STREAMS a_stream 1590977479145-0
# it waits 10 seconds then returns nil
> XDEL a_stream 1590977479145-0
(integer) 1
> XREAD BLOCK 10000 STREAMS a_stream 1590977447146-0
1) 1) "a_stream" # returned immediately
   2) (empty list or set)

Please let me know if more context would be useful.

Comment From: jackmaris

Hello?

Comment From: huangzhw

@jackmaris I check the unstable code. I found this was already solved. https://github.com/redis/redis/blob/0b1b9edb2843730b03f78b6073cdd30873dbba95/src/t_stream.c#L2093 https://github.com/redis/redis/blob/0b1b9edb2843730b03f78b6073cdd30873dbba95/src/t_stream.c#L2104

Comment From: jackmaris

Ah, wonderful. Thank you.