Skip to content

Commit

Permalink
Fix: restore replica output bytes stat update
Browse files Browse the repository at this point in the history
Signed-off-by: Uri Yagelnik <[email protected]>
  • Loading branch information
uriyage committed Dec 24, 2024
1 parent 9f4503c commit b93e66a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -2231,6 +2231,8 @@ int postWriteToClient(client *c) {
server.stat_total_writes_processed++;
if (getClientType(c) != CLIENT_TYPE_REPLICA) {
_postWriteToClient(c);
} else {
server.stat_net_repl_output_bytes += c->nwritten > 0 ? c->nwritten : 0;
}

if (c->write_flags & WRITE_FLAGS_WRITE_ERROR) {
Expand Down
24 changes: 24 additions & 0 deletions tests/integration/replication.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,30 @@ start_server {tags {"repl external:skip"}} {
}
assert_match {*calls=1,*,rejected_calls=0,failed_calls=1*} [cmdrstat blpop $B]
}

test {Replica output bytes metric} {
# reset stats
$A config resetstat

set info [$A info stats]
set replica_bytes_output [getInfoProperty $info "total_net_repl_output_bytes"]
assert_equal $replica_bytes_output 0

# sent set command to primary
$A set key value

# wait for command propagation
wait_for_condition 50 100 {
[$B get key] eq {value}
} else {
fail "Replica did not receive the command"
}

# get the new stats
set info [$A info stats]
set replica_bytes_output [getInfoProperty $info "total_net_repl_output_bytes"]
assert {$replica_bytes_output > 0}
}
}
}

Expand Down

0 comments on commit b93e66a

Please sign in to comment.