diff options
author | Madelyn Olson <34459052+madolson@users.noreply.github.com> | 2022-04-26 03:25:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 13:25:33 +0300 |
commit | 6fa8e4f7afcbd14748c736c38e5fbc117eaef7ba (patch) | |
tree | e74b7ddf889b99daadd615cbee5ca069e14c82bb /src/networking.c | |
parent | efcd1bf394668e418df1a93cd28cf9e8b0c09ce5 (diff) | |
download | redis-6fa8e4f7afcbd14748c736c38e5fbc117eaef7ba.tar.gz |
Set replicas to panic on disk errors, and optionally panic on replication errors (#10504)
* Till now, replicas that were unable to persist, would still execute the commands
they got from the master, now they'll panic by default, and we add a new
`replica-ignore-disk-errors` config to change that.
* Till now, when a command failed on a replica or AOF-loading, it only logged a
warning and a stat, we add a new `propagation-error-behavior` config to allow
panicking in that state (may become the default one day)
Note that commands that fail on the replica can either indicate a bug that could
cause data inconsistency between the replica and the master, or they could be
in some cases (specifically in previous versions), a result of a command (e.g. EVAL)
that failed on the master, but still had to be propagated to fail on the replica as well.
Diffstat (limited to 'src/networking.c')
-rw-r--r-- | src/networking.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/networking.c b/src/networking.c index e79b18d70..0664e2bf0 100644 --- a/src/networking.c +++ b/src/networking.c @@ -539,6 +539,21 @@ void afterErrorReply(client *c, const char *s, size_t len, int flags) { showLatestBacklog(); } server.stat_unexpected_error_replies++; + + /* Based off the propagation error behavior, check if we need to panic here. There + * are currently two checked cases: + * * If this command was from our master and we are not a writable replica. + * * We are reading from an AOF file. */ + int panic_in_replicas = (ctype == CLIENT_TYPE_MASTER && server.repl_slave_ro) + && (server.propagation_error_behavior == PROPAGATION_ERR_BEHAVIOR_PANIC || + server.propagation_error_behavior == PROPAGATION_ERR_BEHAVIOR_PANIC_ON_REPLICAS); + int panic_in_aof = c->id == CLIENT_ID_AOF + && server.propagation_error_behavior == PROPAGATION_ERR_BEHAVIOR_PANIC; + if (panic_in_replicas || panic_in_aof) { + serverPanic("This %s panicked sending an error to its %s" + " after processing the command '%s'", + from, to, cmdname ? cmdname : "<unknown>"); + } } } |