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

WATCH during MULTI shouldn't fail transaction #3009 #3027

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

tishun
Copy link
Collaborator

@tishun tishun commented Oct 24, 2024

Closes #3009

Problem statement
The submit attempts to solve two distinct issues existing in the driver currently:

  1. A neseted WATCH (WATCH called after a MULTI and before an EXEC would result in some of the results in the TransactionResult to be missing, because the error result from the WATCH would push them out
  2. A nested WATCH behaves differently than a nested MULTI, which instead throws an exception (but does not fail the transaction).

In a broader context the Redis server seems to handle errors inside transactions in three different ways:

  • fails the transaction (if for ex. a malformed command is provided inside a transaction)
  • does not fail the transaction, but includes errors in the output after EXEC (in case the command returns an error response, e.g. CLUSTER SLOTS called in a non-clustered environment)
  • does not fail the transaction, but does not include the error in the output after EXEC (nested MULTI and WATCH)

Proposed solution

Make both WATCH and MULTI behave the same way when called inside a transaction:

  • throw an exception to notify the application of an invalid state
  • allow, if the exception is handled, to continue executing the transaction

Benefits

  • this would constitute the minimal amount of deviation from the existing contract.
  • smallest amount of change (not touching the code path of MULTI at all)

Make sure that:

  • You have read the contribution guidelines.
  • You have created a feature request first to discuss your contribution intent. Please reference the feature request ticket number in the pull request.
  • You applied code formatting rules using the mvn formatter:format target. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.

@tishun tishun merged commit 1deb7bd into redis:main Nov 5, 2024
5 checks passed
@tishun tishun added this to the 6.6.0.RELEASE milestone Nov 5, 2024
@tishun tishun deleted the topic/tishun/issue-3009 branch November 5, 2024 12:40
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.

WATCH during MULTI shouldn't fail transaction
1 participant