* Do not follow -ASK on the first command of a cluster transaction
A cluster transaction is held on the node the slots map associates
with its slot, but its first command went through the cluster like any
other one. While a slot was being migrated, an -ASK reply to WATCH (or
to the first command in CAS mode) was followed to the node importing
the slot, and only then was the connection pinned from the slots map,
which -ASK does not update. WATCH was left on the importing node while
MULTI, the queued commands and EXEC ran on the source node with nothing
watched, so the transaction committed even though the watched key had
changed. When the transaction failed after that WATCH, the cleanup was
sent to the source node and the WATCH on the importing node was never
released, so its dirty flag aborted a later, unrelated transaction sent
over the pooled connection.
The first command is now sent through
RedisCluster::executeCommandOnSlotOwner(), which retries and follows
-MOVED and -READONLY like executeCommand() but returns -ASK replies.
The transaction then fails with a ServerException carrying the -ASK
reply, as later CAS commands already did, without touching the
importing node. Retrying once the migration has finished reaches the
new owner. An -ASK reply to a queued command still aborts the
transaction, as before.
The README no longer claims that the first command is redirected like
any other command, and describes how an -ASK reply fails a transaction.
* Add the cluster ASK fix to the changelog
* Unwatch the keys when a server error escapes a transaction block
A transaction block that threw a server error, such as WRONGTYPE from a
command run before multi() in CAS mode, left its WATCH on the connection
because MultiExec ignored the exception. The next transaction on that
connection then failed with a spurious abort once a watched key had
changed. A server error now discards the transaction like any other
exception leaving the block, which sends UNWATCH before MULTI and
DISCARD after it.
* Keep the WATCH of a cluster transaction after a server error
A cluster transaction sent UNWATCH and released its node when a command
run before multi() in CAS mode got an error reply, such as WRONGTYPE
from GET or NOPERM from a second WATCH. A block that caught the error
and went on to multi() then ran MULTI and EXEC on a connection that
watched nothing, so a change to a watched key was silently overwritten.
Redis keeps the WATCH after an error outside MULTI, and so does a
non-cluster transaction, which fails EXEC on a conflicting change.
The node that already holds the transaction now keeps its WATCH and the
error is thrown. A -MOVED reply only updates the slots map: the queued
commands are rejected by that node, so the transaction cannot commit on
the new one without the WATCH. An error on the first command still
releases the node, as nothing is watched yet.
* Add the cluster WATCH fix to the changelog
* Give the CAS MOVED test the slot its WATCH key has
Cluster transactions now retry a MOVED reply only for the transaction's
own slot. The test's mocked strategy returned no slot, which a WATCH
key always has, so its queued MOVED was reported instead of retried.
* Report cluster transaction server errors instead of retrying them
Every error reply to MULTI, to a queued command or to EXEC went through
abort() and made executeTransaction() return null, which
MultiExec::execute() reads as a WATCH conflict. A command Redis
rejected (CROSSSLOT, OOM, wrong arity, BUSY) therefore surfaced as "The
current transaction has been aborted by the server." without the
server's message, and with the retry option the block ran again against
an error that would repeat.
Only the errors a retry can get past still return null: MOVED for the
transaction's own slot, whose abort updates the slots map, TRYAGAIN,
CLUSTERDOWN, READONLY, and the "Transaction failed" error Relay uses to
report a WATCH conflict. Everything else is reported like on a single
node: a rejected queued command is returned to MultiExec, which throws
AbortedMultiExecException with the server's message, and an error from
MULTI or EXEC throws ServerException. Cleanup and slots map updates stay
as they were, and the transaction is reset, so it can be used again.
ASK is reported too. A transaction does not send ASKING, so every retry
reaches the same node and gets the same ASK until the migration ends.
LOADING, BUSY and MASTERDOWN are not retried either, as MultiExec
retries without waiting and single node transactions don't retry them.
* Add the cluster transaction error fix to the changelog
* Avoid a word the spell check rejects in the README
* Drop the Relay case from cluster transaction errors
RelayConnection now returns null when a watched key aborts EXEC, like
the stream connection, so a cluster transaction no longer sees Relay's
"Transaction failed" error and does not need to treat it as retryable.
* Fail cluster transactions after a lost WATCH or a rejected command
A cluster transaction kept in use after losing its connection between
WATCH and MULTI committed on a new connection, without the WATCH. A
block that caught a cross-slot error committed the other commands.
Like with a single node, commands now fail until discard() or unwatch()
once the connection is lost, and EXEC fails with EXECABORT after a
rejected command.
* Add the cluster transaction fixes to the changelog
* Release a cluster transaction even when its cleanup fails
A connection lost while discard() or unwatch() sent UNWATCH marked the
transaction as lost again, after MultiExec had already reset it, so it
stayed unusable.
* Only fail a cluster transaction for commands rejected after MULTI
A cross-slot command before multi() in CAS mode runs on its own and is
never queued, but it still made EXEC fail with EXECABORT, so a block
that caught the error and went on to multi() could not commit, while
Redis and non-cluster transactions commit it.
* Report a lost cluster connection before a rejected command on EXEC
MultiExec now resets once EXEC fails with a server error. A cluster
transaction that lost its connection and also had a command rejected
failed EXEC with EXECABORT, so MultiExec reset and discard() could no
longer release the lost connection, failing every later command. EXEC
now reports the lost connection first, so the transaction keeps its
state until discard(), as it does on a single node.
* Added support for transactions in OSS Cluster
* Updated test cases
* Updated version restriction
* Updated server version restriction
* Added test skip for Relay
* Added test case for Relay
* Set transaction slot to null in case of failed transaction
* Restrict usage of transaction commands outside of transaction context
* Added handling for Relay responses
* Reverted changes
* Removed unsupported command
* Added dummy arguments
* Codestyle fixes
* Added additional test coverage
* Added CHANGELOG and README entries
* Added missing PR reference
* Missing word
* Fixed README