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

Fix some low level stream commands for redis cluster #283

Merged
merged 4 commits into from
Feb 20, 2020

Conversation

FilipStamenkovic
Copy link
Contributor

Fix key position for stream commands:

  • xgroup and xinfo have key position on 3rd place
  • xread and xreadgroup have key right after STREAMS keyword

Small note: xread and xreadgroup command can take multiple streams (multiple keys) and my proposed solution is calculating hash only based on first key.
I think this assumption is correct because 2 things could happen:

  • all stream keys will belong to the same slot, so no point of calculating slot for each key (highly unlikely)
  • some stream keys will map to different slots, then no matter how we calculate routing, redis command will fail with error: (error) CROSSSLOT Keys in request don't hash to the same slot

- xgroup and xinfo they have key position on 3rd place
- xread and xreadgroup have key right after 'STREAMS' keyword
Copy link
Collaborator

@badboy badboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline nit, but I would be ok with merging (and fixing it afterwards)

src/cluster.rs Outdated
b"XREAD" | b"XREADGROUP" => {
let streams_position = args
.iter()
.position(|a| *a == Value::Data(b"STREAMS".to_vec()))?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mini-optimisation: we can pull out the Value::Data(b"STREAMS".to_vec()) before the whole iteration, therefore saving us the frequent re-creation (and thus re-allocation)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that somehow, thanks.

It should be ok now?

src/cluster.rs Outdated Show resolved Hide resolved
src/cluster.rs Outdated Show resolved Hide resolved
src/cluster.rs Outdated Show resolved Hide resolved
@badboy badboy merged commit 66e7435 into redis-rs:master Feb 20, 2020
barshaul pushed a commit to barshaul/redis-rs that referenced this pull request Jul 11, 2024
barshaul pushed a commit to barshaul/redis-rs that referenced this pull request Jul 11, 2024
* Python: add SMOVE command (redis-rs#283)

* Align docs and cross-slot test with recent changes

* Fix formatting
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

Successfully merging this pull request may close these issues.

3 participants