-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[CAE-1028] fix(txpipeline): should return error on multi/exec on multiple slots #3408
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
Conversation
cc1f567
to
3f78c72
Compare
3f78c72
to
9b71da1
Compare
4a708d6
to
68c90f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue in the ClusterClient where multi/exec on multiple slots is not supported by reporting an immediate error. It updates tests to verify the error condition and modifies the pipeline processing logic to return ErrCrossSlot when commands span multiple slots.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
osscluster_test.go | Updates tests to parameterize key sets and verifies cross-slot error handling |
osscluster.go | Adds a check in TxPipeline to return ErrCrossSlot for multi-slot commands |
error.go | Introduces a new error constant ErrCrossSlot with appropriate documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for filing this. I am philosophically aligned with this change, though it does represent a pretty major backwards-incompatible behavior change for users. I wonder if it would make sense to gate the new behavior behind an opt-in option, which can potentially be flipped to opt-out in a future major version.
@LINKIWI a transaction which is cross slot won't be a single transaction anyway and will break the contract of a "multi/exec". If users raise issues, we can safely suggest using pipelines and/or refactoring their code. The possibility to use it as it was, was allowing users to use the database and transactions incorrectly. I see your point about the backwards compatibility, but personally don't see a value in a flag and would prefer not to have one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
One minor nitpick: In the osscluster file, can we swap the places of the IFs? First check if the slice is empty and then check if it contains more than one element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
33aecb8
go-redis
should not try to do some magic and support multi slot transactions. Such cross slot operations are not supported by the database server for a reason and what the library can do is to report an error to the user as soon as possible.Althought this changes the behaviour it is considered a bugfix.
closes #3019