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

Incorrect slot calculation for Xgroup commands using Redis cluster #2982

Closed
daviddzxy opened this issue Apr 26, 2024 · 0 comments
Closed

Incorrect slot calculation for Xgroup commands using Redis cluster #2982

daviddzxy opened this issue Apr 26, 2024 · 0 comments

Comments

@daviddzxy
Copy link
Contributor

daviddzxy commented Apr 26, 2024

Slot calculations for Xgroup commands are incorrect. It turns out that when f.e. XGroupCreateMkStream function is called the func cmdFirstKeyPos(cmd Cmder) int function returns wrong pos number (It returns 1 instead of 2). As a result of this, the function func Slot(key string) int always receives value "create" as argument. This causes incorrectly calculated slot number. Redis will almost always respond with MOVED error and then the command will be resent to the correct node. This bug is related to issue #2978. I will try to provide PR with a fix.

Expected Behavior

Client should calculate slot for a given key correctly.

Current Behavior

Client does not calculate slot for a given key correctly.

Possible Solution

Use cmd.SetFirstKeyPos(2) in func (c cmdable) XGroupCreate(ctx context.Context, stream, group, start string) *StatusCmd and in others.

Steps to Reproduce

  1. Start redis in cluster mode
  2. Call function XGroupCreate with valid arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant