Skip to content

Commit

Permalink
Fix cluster info sent stats for message with light header (#1563)
Browse files Browse the repository at this point in the history
This issue affected only two message types (CLUSTERMSG_TYPE_PUBLISH and CLUSTERMSG_TYPE_PUBLISHSHARD) because they used a light message header, which caused the CLUSTER INFO stats to miss sent/received message information for those types.

---------

Signed-off-by: Harkrishn Patro <[email protected]>
Signed-off-by: Harkrishn Patro <[email protected]>
Co-authored-by: Binbin <[email protected]>
  • Loading branch information
hpatro and enjoy-binbin authored Jan 16, 2025
1 parent af71619 commit 87cc3d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -3920,7 +3920,7 @@ void clusterSendMessage(clusterLink *link, clusterMsgSendBlock *msgblock) {
server.stat_cluster_links_memory += sizeof(listNode);

/* Populate sent messages stats. */
uint16_t type = ntohs(getMessageFromSendBlock(msgblock)->type);
uint16_t type = ntohs(getMessageFromSendBlock(msgblock)->type) & ~CLUSTERMSG_MODIFIER_MASK;
if (type < CLUSTERMSG_TYPE_COUNT) server.cluster->stats_bus_messages_sent[type]++;
}

Expand Down
14 changes: 13 additions & 1 deletion tests/unit/cluster/pubsub.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,17 @@ test "Test publishing to master" {
test "Test publishing to slave" {
test_cluster_publish 5 10
}

} ;# start_cluster

start_cluster 3 0 {tags {external:skip cluster}} {
test "Test cluster info stats for publish" {
R 0 PUBLISH hello world
assert_equal 2 [CI 0 cluster_stats_messages_publish_sent]
wait_for_condition 50 100 {
[CI 1 cluster_stats_messages_publish_received] eq 1 &&
[CI 2 cluster_stats_messages_publish_received] eq 1
} else {
fail "node 2 or node 3 didn't receive clusterbus publish packet"
}
}
}

0 comments on commit 87cc3d7

Please sign in to comment.