Skip to content

Commit

Permalink
Assert network bytes out for replication slot stat computation is onl…
Browse files Browse the repository at this point in the history
…y allowed on primary (#847)

Added an assertion to avoid incorrect usage of the network bytes out for
replication code flow in slot stats computation.

Signed-off-by: Harkrishn Patro <[email protected]>
  • Loading branch information
hpatro authored Aug 7, 2024
1 parent 380f700 commit 109cc21
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/cluster_slot_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ static void clusterSlotStatsUpdateNetworkBytesOutForReplication(long long len) {
if (c == NULL || !canAddNetworkBytesOut(c)) return;

serverAssert(c->slot >= 0 && c->slot < CLUSTER_SLOTS);
serverAssert(nodeIsPrimary(server.cluster->myself));
if (len < 0) serverAssert(server.cluster->slot_stats[c->slot].network_bytes_out >= (uint64_t)llabs(len));
server.cluster->slot_stats[c->slot].network_bytes_out += (len * listLength(server.replicas));
}
Expand Down

0 comments on commit 109cc21

Please sign in to comment.