mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
Transactions: use the propagate() API to propagate MULTI.
The behavior is the same, but the code is now cleaner and uses the proper interface instead of dealing directly with AOF/replication functions.
This commit is contained in:
parent
afce010639
commit
2f49734029
11
src/multi.c
11
src/multi.c
@ -103,12 +103,11 @@ void discardCommand(redisClient *c) {
|
|||||||
|
|
||||||
/* Send a MULTI command to all the slaves and AOF file. Check the execCommand
|
/* Send a MULTI command to all the slaves and AOF file. Check the execCommand
|
||||||
* implementation for more information. */
|
* implementation for more information. */
|
||||||
void execCommandReplicateMulti(redisClient *c) {
|
void execCommandPropagateMulti(redisClient *c) {
|
||||||
robj *multistring = createStringObject("MULTI",5);
|
robj *multistring = createStringObject("MULTI",5);
|
||||||
|
|
||||||
if (server.aof_state != REDIS_AOF_OFF)
|
propagate(server.multiCommand,c->db->id,&multistring,1,
|
||||||
feedAppendOnlyFile(server.multiCommand,c->db->id,&multistring,1);
|
REDIS_PROPAGATE_AOF|REDIS_PROPAGATE_REPL);
|
||||||
replicationFeedSlaves(server.slaves,c->db->id,&multistring,1);
|
|
||||||
decrRefCount(multistring);
|
decrRefCount(multistring);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,11 +138,11 @@ void execCommand(redisClient *c) {
|
|||||||
goto handle_monitor;
|
goto handle_monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Replicate a MULTI request now that we are sure the block is executed.
|
/* Propagate a MULTI request now that we are sure the block is executed.
|
||||||
* This way we'll deliver the MULTI/..../EXEC block as a whole and
|
* This way we'll deliver the MULTI/..../EXEC block as a whole and
|
||||||
* both the AOF and the replication link will have the same consistency
|
* both the AOF and the replication link will have the same consistency
|
||||||
* and atomicity guarantees. */
|
* and atomicity guarantees. */
|
||||||
execCommandReplicateMulti(c);
|
execCommandPropagateMulti(c);
|
||||||
|
|
||||||
/* Exec all the queued commands */
|
/* Exec all the queued commands */
|
||||||
unwatchAllKeys(c); /* Unwatch ASAP otherwise we'll waste CPU cycles */
|
unwatchAllKeys(c); /* Unwatch ASAP otherwise we'll waste CPU cycles */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user