Skip to content

[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

Merged
merged 6 commits into from
Jun 18, 2025

Conversation

ndyakov
Copy link
Member

@ndyakov ndyakov commented Jun 16, 2025

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

@ndyakov ndyakov added the bug label Jun 16, 2025
@ndyakov ndyakov force-pushed the ndyakov/CAE-1028-tx-pipeline-cluster-mode branch from cc1f567 to 3f78c72 Compare June 16, 2025 16:12
@ndyakov ndyakov force-pushed the ndyakov/CAE-1028-tx-pipeline-cluster-mode branch from 3f78c72 to 9b71da1 Compare June 16, 2025 17:00
@ndyakov ndyakov changed the title WIP!: fix(txpipeline): should return error on multi/exec on multiple slots [CAE-1028] fix(txpipeline): should return error on multi/exec on multiple slots Jun 17, 2025
Copilot

This comment was marked as outdated.

@ndyakov ndyakov force-pushed the ndyakov/CAE-1028-tx-pipeline-cluster-mode branch from 4a708d6 to 68c90f7 Compare June 17, 2025 09:08
@ndyakov ndyakov requested a review from Copilot June 17, 2025 10:16
Copy link
Contributor

@Copilot Copilot AI left a 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

Copy link
Contributor

@LINKIWI LINKIWI left a 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.

@ndyakov
Copy link
Member Author

ndyakov commented Jun 17, 2025

@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.

Copy link

@htemelski-redis htemelski-redis left a 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.

Copy link

@htemelski-redis htemelski-redis left a comment

Choose a reason for hiding this comment

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

LGTM

elena-kolevska
elena-kolevska previously approved these changes Jun 17, 2025
@ndyakov ndyakov dismissed stale reviews from elena-kolevska and htemelski-redis via 33aecb8 June 18, 2025 08:08
@ndyakov ndyakov merged commit 4c635cc into master Jun 18, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Why does go-redis allow cluster mode cross-shard transactions and pipelines?
4 participants