Propagation: wrap commands in also_propagate array with MULIT/EXEC

Random command like SPOP with count is replicated as
some SREM operations, and store them in also_propagate
array to propagate after the call, but this would break
atomicity.

To keep the command's atomicity, wrap also_propagate
array with MULTI/EXEC.
This commit is contained in:
zhaozhao.zz
2019-11-22 15:42:49 +08:00
parent b93945585a
commit 37a10cef02
5 changed files with 27 additions and 11 deletions
+5 -3
View File
@@ -106,11 +106,13 @@ void discardCommand(client *c) {
/* Send a MULTI command to all the slaves and AOF file. Check the execCommand
* implementation for more information. */
void execCommandPropagateMulti(client *c) {
robj *multistring = createStringObject("MULTI",5);
propagate(server.multiCommand,c->db->id,&shared.multi,1,
PROPAGATE_AOF|PROPAGATE_REPL);
}
propagate(server.multiCommand,c->db->id,&multistring,1,
void execCommandPropagateExec(client *c) {
propagate(server.execCommand,c->db->id,&shared.exec,1,
PROPAGATE_AOF|PROPAGATE_REPL);
decrRefCount(multistring);
}
void execCommand(client *c) {