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
| 4363 | * want to use propagate(). |
| 4364 | */ |
| 4365 | void propagate(struct redisCommand *cmd, int dbid, robj **argv, int argc, |
| 4366 | int flags) |
| 4367 | { |
| 4368 | serverAssert(GlobalLocksAcquired()); |
| 4369 | if (!g_pserver->replication_allowed) |
| 4370 | return; |
| 4371 | |
| 4372 | /* Propagate a MULTI request once we encounter the first command which |
| 4373 | * is a write command. |
| 4374 | * This way we'll deliver the MULTI/..../EXEC block as a whole and |
| 4375 | * both the AOF and the replication link will have the same consistency |
| 4376 | * and atomicity guarantees. */ |
| 4377 | if (serverTL->in_exec && !serverTL->propagate_in_transaction) |
| 4378 | execCommandPropagateMulti(dbid); |
| 4379 | |
| 4380 | /* This needs to be unreachable since the dataset should be fixed during |
| 4381 | * client pause, otherwise data may be lossed during a failover. */ |
| 4382 | serverAssert(!(areClientsPaused() && !serverTL->client_pause_in_transaction)); |
| 4383 | |
| 4384 | if (g_pserver->aof_state != AOF_OFF && flags & PROPAGATE_AOF) |
| 4385 | feedAppendOnlyFile(cmd,dbid,argv,argc); |
| 4386 | if (flags & PROPAGATE_REPL) |
| 4387 | replicationFeedSlaves(g_pserver->slaves,dbid,argv,argc); |
| 4388 | } |
| 4389 | |
| 4390 | /* Used inside commands to schedule the propagation of additional commands |
| 4391 | * after the current command is propagated to AOF / Replication. |
no test coverage detected