go-redis: XClaim does not work as expected
Issue tracker is used for reporting bugs and discussing new features. Please use stackoverflow for supporting issues.
EDIT: this is not a bug but an expected behavior of Redis Stream Related issues:
- https://github.com/redis/redis/issues/7021
- https://github.com/redis/redis/issues/10198
- https://github.com/redis/redis/issues/8924
Expected Behavior
The XClaim method should return the list of claimed messages (XMessages) (as specified in the document https://redis.io/commands/xclaim/ Return section), and err = nil in case of success event
Current Behavior
-
It claim the messages successfully (I checked RedisInsight and I see that the messages were claimed)

-
The returned XMessages is nil, while the err = redis: nil

Possible Solution
Steps to Reproduce
xMessages, err := s.client.XClaim(ctx, &redis.XClaimArgs{
Stream: "stream-name",
Group: "consumer-group-name",
Consumer: "consumer-name",
MinIdle: 30 * time.Second,
Messages: <list of messages>,
}).Result()
if err != nil {
return nil, err // <= it will run into this section
}
...
Context (Environment)
I’m trying to use XPendingExt and XClaim to set up a workflow that if one consumer dies unexpectedly, another consumer can take the unprocessed messages and continue to process them (so that no messages are loss without being processed)
Detailed Description
Possible Implementation
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 25
It depends on what your goal is. Only use the XDEL/XTRIM command to remove messages when you are sure that the messages will never be used again.
If your STREAMS are used by multiple groups, deleting STREAMS messages will affect other groups. You can consider other commands, such as XACK that you mentioned, or XGROUP DELCONSUMER.
Removing messages from STREAMS should be done very carefully and only when you are certain that the messages are no longer being used anywhere, including by groups, xread, xrange, consumers, or any other applications.
This is because the design principle of STREAMS is for multiple processes to share the reading of messages, and messages should not be removed from STREAMS simply because a consumer has already consumed them.