Propagate the specified command (in the context of the specified database id) * to AOF and Slaves. * * flags are an xor between: * + PROPAGATE_NONE (no propagation of command at all) * + PROPAGATE_AOF (propagate into the AOF file if is enabled) * + PROPAGATE_REPL (propagate into the replication link) * * This should not be used inside commands implementation since it will not * wrap the r
| 3574 | * want to use propagate(). |
| 3575 | */ |
| 3576 | void propagate(struct redisCommand *cmd, int dbid, robj **argv, int argc, |
| 3577 | int flags) |
| 3578 | { |
| 3579 | if (!server.replication_allowed) |
| 3580 | return; |
| 3581 | |
| 3582 | /* Propagate a MULTI request once we encounter the first command which |
| 3583 | * is a write command. |
| 3584 | * This way we'll deliver the MULTI/..../EXEC block as a whole and |
| 3585 | * both the AOF and the replication link will have the same consistency |
| 3586 | * and atomicity guarantees. */ |
| 3587 | if (server.in_exec && !server.propagate_in_transaction) |
| 3588 | execCommandPropagateMulti(dbid); |
| 3589 | |
| 3590 | /* This needs to be unreachable since the dataset should be fixed during |
| 3591 | * client pause, otherwise data may be lossed during a failover. */ |
| 3592 | serverAssert(!(areClientsPaused() && !server.client_pause_in_transaction)); |
| 3593 | |
| 3594 | if (server.aof_state != AOF_OFF && flags & PROPAGATE_AOF) |
| 3595 | feedAppendOnlyFile(cmd,dbid,argv,argc); |
| 3596 | if (flags & PROPAGATE_REPL) |
| 3597 | replicationFeedSlaves(server.slaves,dbid,argv,argc); |
| 3598 | } |
| 3599 | |
| 3600 | /* Used inside commands to schedule the propagation of additional commands |
| 3601 | * after the current command is propagated to AOF / Replication. |
no test coverage detected