summaryrefslogtreecommitdiff
path: root/src/networking.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-05-05 13:40:33 +0200
committerantirez <antirez@gmail.com>2020-05-08 10:37:36 +0200
commit84d9766d6a4bc04a642bfec3b82386483dd452c5 (patch)
tree549e4ffe61726116f67eb82f4629f1b28ae5c370 /src/networking.c
parentec1e106ec5c4ef9fd71d3ab3a6137012120058f4 (diff)
downloadredis-84d9766d6a4bc04a642bfec3b82386483dd452c5.tar.gz
Dump recent backlog on master query generating errors.
Diffstat (limited to 'src/networking.c')
-rw-r--r--src/networking.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/networking.c b/src/networking.c
index fd1159e06..75c0c16b1 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -393,6 +393,35 @@ void addReplyErrorLength(client *c, const char *s, size_t len) {
serverLog(LL_WARNING,"== CRITICAL == This %s is sending an error "
"to its %s: '%s' after processing the command "
"'%s'", from, to, s, cmdname);
+ if (ctype == CLIENT_TYPE_MASTER && server.repl_backlog &&
+ server.repl_backlog_histlen > 0)
+ {
+ long long dumplen = 256;
+ if (server.repl_backlog_histlen < dumplen)
+ dumplen = server.repl_backlog_histlen;
+
+ /* Identify the first byte to dump. */
+ long long idx =
+ (server.repl_backlog_idx + (server.repl_backlog_size - dumplen)) %
+ server.repl_backlog_size;
+
+ /* Scan the circular buffer to collect 'dumplen' bytes. */
+ sds dump = sdsempty();
+ while(dumplen) {
+ long long thislen =
+ ((server.repl_backlog_size - idx) < dumplen) ?
+ (server.repl_backlog_size - idx) : dumplen;
+
+ dump = sdscatrepr(dump,server.repl_backlog+idx,thislen);
+ dumplen -= thislen;
+ idx = 0;
+ }
+
+ /* Finally log such bytes: this is vital debugging info to
+ * understand what happened. */
+ serverLog(LL_WARNING,"Latest backlog is: '%s'", dump);
+ sdsfree(dump);
+ }
server.stat_unexpected_error_replies++;
}
}