Skip to content

Commit

Permalink
Detail the issue of redirection occurring within a transaction. (#168)
Browse files Browse the repository at this point in the history
doc for valkey-io/valkey#895

---------

Signed-off-by: zhaozhao.zz <[email protected]>
Co-authored-by: Madelyn Olson <[email protected]>
  • Loading branch information
soloestoy and madolson authored Dec 11, 2024
1 parent c367da6 commit 397bc46
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion topics/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,52 @@ 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.

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.

For cluster mode:

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

For standalone mode:

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

Before the `EXEC` command is processed, if a command accesses data that does not belong to the current node,
a `-MOVED` or `-REDIRECT` error will be returned immediately, and the `EXEC` command will receive an `EXECABORT` error.

For cluster mode:

```
MULTI ==> +OK
SET x y ==> -MOVED
EXEC ==> -EXECABORT
```

For standalone mode:

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

## What about rollbacks?

Expand Down

0 comments on commit 397bc46

Please sign in to comment.