From e8eeba7bee6add5286afc4d59db074a924fb9209 Mon Sep 17 00:00:00 2001 From: Qu Chen Date: Sun, 8 Aug 2021 17:34:11 -0700 Subject: [PATCH] Allow master to replicate command longer than replica's query buffer limit (#9340) Replication client no longer checks incoming command length against the client-query-buffer-limit. This makes the master able to replicate commands longer than replica's configured client-query-buffer-limit --- src/networking.c | 2 +- tests/integration/replication-3.tcl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/networking.c b/src/networking.c index ff14a5a32b..9753e3f618 100644 --- a/src/networking.c +++ b/src/networking.c @@ -2196,7 +2196,7 @@ void readQueryFromClient(connection *conn) { c->lastinteraction = server.unixtime; if (c->flags & CLIENT_MASTER) c->read_reploff += nread; atomicIncr(server.stat_net_input_bytes, nread); - if (sdslen(c->querybuf) > server.client_max_querybuf_len) { + if (!(c->flags & CLIENT_MASTER) && sdslen(c->querybuf) > server.client_max_querybuf_len) { sds ci = catClientInfoString(sdsempty(),c), bytes = sdsempty(); bytes = sdscatrepr(bytes,c->querybuf,64); diff --git a/tests/integration/replication-3.tcl b/tests/integration/replication-3.tcl index edd3b71deb..642b99a0cb 100644 --- a/tests/integration/replication-3.tcl +++ b/tests/integration/replication-3.tcl @@ -31,6 +31,19 @@ start_server {tags {"repl external:skip"}} { assert_equal [r debug digest] [r -1 debug digest] } + test {Master can replicate command longer than client-query-buffer-limit on replica} { + # Configure the master to have a bigger query buffer limit + r config set client-query-buffer-limit 2000000 + r -1 config set client-query-buffer-limit 1048576 + # Write a very large command onto the master + r set key [string repeat "x" 1100000] + wait_for_condition 300 100 { + [r -1 get key] eq [string repeat "x" 1100000] + } else { + fail "Unable to replicate command longer than client-query-buffer-limit" + } + } + test {Slave is able to evict keys created in writable slaves} { r -1 select 5 assert {[r -1 dbsize] == 0}