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

Create stream consumer group will make the xread command error #2109

Closed
2 tasks done
jihuayu opened this issue Feb 21, 2024 · 2 comments · Fixed by #2112
Closed
2 tasks done

Create stream consumer group will make the xread command error #2109

jihuayu opened this issue Feb 21, 2024 · 2 comments · Fixed by #2112
Labels
bug type bug

Comments

@jihuayu
Copy link
Member

jihuayu commented Feb 21, 2024

Search before asking

  • I had searched in the issues and found no similar issues.

Version

unstable

Minimal reproduce step

XADD test * a a
XGROUP create test test 0
xread STREAMS test 0

What did you expect to see?

1) 1) "test"
   2) 1) 1) "1708506496723-0"
         2) 1) "a"
            2) "a"

What did you see instead?

(error) ERR Invalid argument: failed to decode stream entry value

Anything Else?

I discovered this when developing the xreadgroup command.

The subkey of the consumer group overlapped with the subkey of the stream entry.
This causes the range function to get the stream Entry with the group's subkey.

I think there is something wrong with the subkey design of the consumer & consumer group metadata.

std::string Stream::internalKeyFromGroupName(const std::string &ns_key, const StreamMetadata &metadata,
const std::string &group_name) const {
std::string sub_key;
PutFixed64(&sub_key, group_name.size());
sub_key += group_name;
sub_key += consumerGroupMetadataDelimiter;
std::string entry_key = InternalKey(ns_key, sub_key, metadata.version, storage_->IsSlotIdEncoded()).Encode();
return entry_key;
}

I don't really understand why we puts the consumerGroupMetadataDelimiter at the end of the subkey. Shouldn't we put it at the start?

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@jihuayu jihuayu added the bug type bug label Feb 21, 2024
jihuayu added a commit to jihuayu/incubator-kvrocks that referenced this issue Feb 22, 2024
@Yangsx-1
Copy link
Contributor

Good catch! I'm still working on XREADGROUP and will finish it in a few days, and this bug may caused by no subkey identification in the original stream commands. :(

@jihuayu
Copy link
Member Author

jihuayu commented Feb 23, 2024

@Yangsx-1 Thank you. I have fixed this bug, please review it.

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

Successfully merging a pull request may close this issue.

2 participants