Files
Andrei Fedoseev 1cc16c359c Discard a fluent transaction when Redis rejects a queued command (#1755)
When Redis rejected a command while queueing it (OOM, READONLY, NOPERM, MISCONF, wrong arity), MultiExec threw AbortedMultiExecException without sending DISCARD.

A transaction block discards on the way out, the fluent interface didn't, so the connection stayed in MULTI and every later command on the client returned QUEUED without running.

The fluent interface now discards the transaction, or closes the connection if DISCARD fails too.

Until discard() is called, the aborted MultiExec refuses new commands and execute(), so a caller that catches the exception can't commit only the commands queued after the failed one.

Cluster connections skip the abort path: their errors before execute()
come from the client and nothing is queued on a node yet. watch() refuses
to run on an aborted transaction and unwatch() sends nothing, so only
discard() makes it usable again. Every discard on the way out closes the
connection when DISCARD fails.
2026-11-12 11:01:48 -07:00
..