Adds Lua transaction support #2701

Open
wants to merge 1 commit into
from

Projects

None yet

5 participants

@josiahcarlson

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

@nicpottier

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

@flip111
flip111 commented Jul 30, 2015

👍

@badboy badboy commented on the diff Jul 30, 2015
src/cluster.c
@@ -4440,6 +4440,110 @@ void restoreCommand(client *c) {
server.dirty++;
}
+void prepareRollback(struct redisCommand *cmd, client *c) {
@badboy
badboy Jul 30, 2015 Contributor

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

@josiahcarlson
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
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.

@josiahcarlson

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
Features:
* New commands: EVALTXN, EVALSHATXN, ROLLBACK
* EVALTXN and EVALSHATXN allow writes to be rolled back via ROLLBACK command
  outside of scripts, and redis.ROLLBACK() inside Lua scripts

Todo:
* 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, ...)
3a70fae
@tzudot
tzudot commented Aug 12, 2015

👍

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