EXEC without MULTI
Production Risk
Low. This is a simple protocol violation that is easily caught and fixed.
This error occurs when a client sends an EXEC command but is not currently in a transaction state. A transaction must first be initiated with the MULTI command.
- 1A client library bug where EXEC is called improperly.
- 2A client connection was dropped and reconnected, losing the transaction context, but the application logic tried to EXEC anyway.
- 3Manual execution of EXEC in a CLI session without first typing MULTI.
A client sends an EXEC command on a fresh connection.
EXEC
expected output
(error) ERR EXEC without MULTI
Fix 1
Wrap the transaction in a MULTI/EXEC block
WHEN Always, when using transactions
MULTI INCR mycounter EXEC
Why this works
The MULTI command initiates a transaction block. All subsequent commands are queued until EXEC is called, which executes them atomically.
Fix 2
Use a client library's transaction abstraction
WHEN In application code
// node-redis example
await client.multi().incr('mycounter').exec();Why this works
High-level client libraries provide abstractions that ensure MULTI, the queued commands, and EXEC are called in the correct order, preventing this error.
✕ Send EXEC and hope for the best
It will always fail if not preceded by MULTI in the same session. The protocol is stateful and strict.
Transaction state machine in connection handling.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev