There seems to be some confusion about the new Redis command:
MULTI/EXEC/DISCARD which is confused for transactional support. While there are some similarities, let’s take a quick look at what
MULTI/EXEC/DISCARD really is :
- the commands inside a
MULTI/EXECare batched together and executed at once. Basically none of the commands is executed until the
EXECis emitted. In other words, you can say that the commands in a
MULTI/EXECblock are serialized and executed sequentially. This part of
MULTI/EXEC/DISCARDis indeed similar to transaction semantics and can be considered to be the Atomic part
- there is also a guarantee that no other commands will be executed in the middle of a
MULTI/EXEC(nb right now I’m not sure this is a guarantee of this command implementation or just a consequence of Redis being single-threaded). Anyways, this guarantee could be translated as the Isolation and Consistent parts of a transaction
But here is where the similarities are ending. As you probably know already there is no Durability guarantee in Redis, except the case you configured Redis to use the Append Only File persistence with sync every command which will slow down Redis quite a bit.
But even if we leave aside the Durability aspect, there is another interesting difference:
even when a command will raise an error, all the other commands in the queue will be processed. Redis will NOT stop the processing of commands once an error is found.
And I’d say this is the fundamental difference between Redis
MULTI/EXEC/DISCARD and transaction semantics.
DISCARD doesn’t seem to be equivalent to
ROLLBACK and that means that both Isolation and Consistency guarantees are broken.
In conclusion, I’d say that
MULTI/EXEC/DISCARD while being a very useful and interesting addition, is just a batched serialized execution of a set of commands that partially covers the semantics of ACID transactions.
-  It my be the case I’m the one confused though. (↩)
My comments are based on the documentation for
MULTI/EXEC/DISCARDfound ☞ here and a conversation I’ve had on Twitter (↩)
According to the documentation (nb the important part IMO is “no commands will be executed”, pointing out that you either end a
EXECis called you’ll have to manually rollback changes to gain real transaction semantics): (↩)
DISCARD can be used in order to abort a transaction. No command will be executed, and the state of the client is again the normal one, outside of a transaction.