Describe the bug
After last element of stream was removed, XREAD STREAMS stream + returns nil, but stream is not empty.
To reproduce
127.0.0.1:6379> XADD stream * f 1
"1730271076300-0"
127.0.0.1:6379> XADD stream * f 2
"1730271126476-0"
127.0.0.1:6379> XREAD STREAMS stream +
1) 1) "stream"
2) 1) 1) "1730271126476-0"
2) 1) "f"
2) "2"
127.0.0.1:6379> XREVRANGE stream + - COUNT 1
1) 1) "1730271126476-0"
2) 1) "f"
2) "2"
127.0.0.1:6379> XDEL stream 1730271126476-0
(integer) 1
127.0.0.1:6379> XREVRANGE stream + - COUNT 1
1) 1) "1730271076300-0"
2) 1) "f"
2) "1"
127.0.0.1:6379> XREAD STREAMS stream +
(nil)
127.0.0.1:6379>
Expected behavior
The same as for XREVRANGE stream + - COUNT 1
Additional information
Redis server info:
redis_version:7.4.1
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:7fd3520e9c14a41b
redis_mode:standalone
os:Linux 5.16.17-sun50iw6 aarch64
arch_bits:64
monotonic_clock:POSIX clock_gettime
multiplexing_api:epoll
atomicvar_api:c11-builtin
gcc_version:10.2.1
apt version: 6:7.4.1-1rl1~bullseye1 installed from https://packages.redis.io/deb
Comment From: sundb
@edkalina thanks, the reason is that XDEL forgot to update the last_id when the deleted entries is the last one.
do you wanna make a PR to fix it?