Adds Lua transaction support #2701

wants to merge 1 commit into


None yet

5 participants


Adds 2 commands: EVALTXN and EVALSHATXN - runs Lua scripts in a transaction
Adds 1 script sub-comand: SCRIPT ROLLBACK - kills scripts that have written if they are execued as a transaction
Adds 1 configuration option: lua-all-transactions - for specifying that all EVAL/EVALSHA should be transactions too


+1 to the inclusion of this feature (though can't comment on this particular implementation)

flip111 commented Jul 30, 2015


@badboy badboy commented on the diff Jul 30, 2015
@@ -4440,6 +4440,110 @@ void restoreCommand(client *c) {
+void prepareRollback(struct redisCommand *cmd, client *c) {
badboy Jul 30, 2015 Contributor

Any reason for this being in cluster.c? It does work in normal Redis, right?

josiahcarlson Jul 30, 2015

Three reasons:

  1. I didn't know where else to put it (so I am happy to move it)
  2. The current implementation is an automatic dump/restore
  3. Most of the guts of dump/restore are defined in cluster.c, implemented earlier in the file

Where should I move it?

badboy Jul 30, 2015 Contributor

Not sure where to move. Just wondered if this was a thoughtful decision or just happened to be there for no reason.


The implementation needs to be better long-term. Someone else will have to judge whether the implementation with documentation/caveats is good enough for now.

@josiahcarlson josiahcarlson referenced this pull request in josiahcarlson/redis Aug 8, 2015
@josiahcarlson josiahcarlson Initial commit of Lua transactions
* EVALTXN and EVALSHATXN allow writes to be rolled back via ROLLBACK command
  outside of scripts, and redis.ROLLBACK() inside Lua scripts

* Valgrind
* More tests
* Use hash/dict instead of linked list for rollback items
* Maybe merge ROLLBACK command and redis.ROLLBACK(), or hook in some other place
* Other rollback methods instead of taking a dump of keys written to (fork,
  slave read, pre-persisted from AOF, ...)
tzudot commented Aug 12, 2015


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment