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

Detail the issue of redirection occurring within a transaction. #168

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion topics/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,37 @@ MULTI
+OK
INCR a b c
-ERR wrong number of arguments for 'incr' command
EXEC
-EXECABORT Transaction discarded because of previous errors.
```

This time due to the syntax error the bad `INCR` command is not queued
at all.
at all. And the `EXEC` command will receive an `EXECABORT` error.

There are some more specific scenarios: in the `MULTI` context, commands are
successfully queued (i.e., `QUEUED` reply is received), but when the `EXEC` command
is executed, it is found that the data needed for these commands does not belong to
the current node (for example, in cluster mode, the accessed slot has been migrated to
another node; in standalone mode, a primary-replica switch has occurred). In this case,
the `EXEC` command will receive a `MOVED` or `REDIRECT` result.
Comment on lines +130 to +135
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
There are some more specific scenarios: in the `MULTI` context, commands are
successfully queued (i.e., `QUEUED` reply is received), but when the `EXEC` command
is executed, it is found that the data needed for these commands does not belong to
the current node (for example, in cluster mode, the accessed slot has been migrated to
another node; in standalone mode, a primary-replica switch has occurred). In this case,
the `EXEC` command will receive a `MOVED` or `REDIRECT` result.
When the `EXEC` command is processed, the server will check if a failover or slot migration has occurred since queuing the commands.
If either event has occurred, a `-MOVED` or `-REDIRECT` error will be returned if needed without processing the transaction.

I think just being a bit more succinct for what the user will see might make the English problem easier?

Copy link
Member

Choose a reason for hiding this comment

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

can we also clarify when -MOVED/-REDIRECR would be expected as well? I feel like the table (option 1) at valkey-io/valkey#895 (comment) is very helpful. It would be great if it could be incorporated in this doc.


For cluster mode:

```
MULTI ==> +OK
SET x y ==> +QUEUED
slot {x} is migrated to other node
EXEC ==> -MOVED
Copy link
Member

Choose a reason for hiding this comment

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

I didn't see the EXECABORT behavior documented in this file or anywhere in the doc repo. Can we add it here too for completeness?

```

For standalone mode:

```
MULTI ==> +OK
SET x y ==> +QUEUED
failover
EXEC ==> -REDIRECT
```

## What about rollbacks?

Expand Down