Skip to content

Commit 75fcba6

Browse files
nagleraPing Xie
authored andcommitted
Dual Channel Replication - Verify Replica Local Buffer Limit Configuration (valkey-io#989)
Prior to comparing the replica buffer against the configured limit, we need to ensure that the limit configuration is enabled. If the limit is set to zero, it indicates that there is no limit, and we should skip the buffer limit check. --------- Signed-off-by: naglera <[email protected]> Signed-off-by: Ping Xie <[email protected]>
1 parent 1ef0875 commit 75fcba6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/replication.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2805,7 +2805,8 @@ void bufferReplData(connection *conn) {
28052805
remaining_bytes = readIntoReplDataBlock(conn, tail, remaining_bytes);
28062806
}
28072807
if (readlen && remaining_bytes == 0) {
2808-
if (server.pending_repl_data.len > server.client_obuf_limits[CLIENT_TYPE_REPLICA].hard_limit_bytes) {
2808+
if (server.client_obuf_limits[CLIENT_TYPE_REPLICA].hard_limit_bytes &&
2809+
server.pending_repl_data.len > server.client_obuf_limits[CLIENT_TYPE_REPLICA].hard_limit_bytes) {
28092810
serverLog(LL_NOTICE, "Replication buffer limit reached, stopping buffering.");
28102811
/* Stop accumulating primary commands. */
28112812
connSetReadHandler(conn, NULL);

tests/integration/replication-buffer.tcl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ start_server {} {
132132
# with master.
133133
$master config set repl-timeout 1000
134134
$replica1 config set repl-timeout 1000
135+
$replica1 config set client-output-buffer-limit "replica 1024 0 0"
135136
$replica2 config set repl-timeout 1000
136-
$replica2 config set client-output-buffer-limit "replica 0 0 0"
137+
$replica2 config set client-output-buffer-limit "replica 1024 0 0"
137138
$replica2 config set dual-channel-replication-enabled $dualchannel
138139

139140
$replica1 replicaof $master_host $master_port

0 commit comments

Comments
 (0)