From a51918209cbfcb0a3c5f58a0d6d51115c14a56dd Mon Sep 17 00:00:00 2001 From: Alexandre Antonio Juca Date: Tue, 22 Apr 2025 02:16:10 +0100 Subject: [PATCH 1/4] Fix grammar and typos (#13803) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This MR includes minor improvements and grammatical fixes in the documentation. Specifically: • Corrected grammatical mistakes in sentences for better clarity. • Fixed typos and improved phrasing to enhance readability. • Ensured consistency in terminology and sentence structure. --------- Co-authored-by: debing.sun --- src/cluster_legacy.c | 2 +- src/cluster_legacy.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 2555f9508..32efd2b24 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -2602,7 +2602,7 @@ uint32_t writePingExt(clusterMsg *hdr, int gossipcount) { totlen += getShardIdPingExtSize(); extensions++; - /* Populate insternal secret */ + /* Populate internal secret */ if (cursor != NULL) { clusterMsgPingExtInternalSecret *ext = preparePingExt(cursor, CLUSTERMSG_EXT_TYPE_INTERNALSECRET, getInternalSecretPingExtSize()); memcpy(ext->internal_secret, server.cluster->internal_secret, CLUSTER_INTERNALSECRETLEN); diff --git a/src/cluster_legacy.h b/src/cluster_legacy.h index 730746657..4907ea0e2 100644 --- a/src/cluster_legacy.h +++ b/src/cluster_legacy.h @@ -231,7 +231,7 @@ typedef struct { uint16_t ver; /* Protocol version, currently set to 1. */ uint16_t port; /* Primary port number (TCP or TLS). */ uint16_t type; /* Message type */ - uint16_t count; /* Only used for some kind of messages. */ + uint16_t count; /* Only used for some kinds of messages. */ uint64_t currentEpoch; /* The epoch accordingly to the sending node. */ uint64_t configEpoch; /* The config epoch if it's a master, or the last epoch advertised by its master if it is a @@ -258,8 +258,8 @@ typedef struct { * especially during cluster rolling upgrades. * * Therefore, fields in this struct should remain at the same offset from - * release to release. The static asserts below ensures that incompatible - * changes in clusterMsg be caught at compile time. + * release to release. The static asserts below ensure that incompatible + * changes in clusterMsg are caught at compile time. */ static_assert(offsetof(clusterMsg, sig) == 0, "unexpected field offset"); From 8468ded6679b2109ff926e5302d8db40ed42b4ee Mon Sep 17 00:00:00 2001 From: nesty92 Date: Tue, 22 Apr 2025 04:11:10 +0200 Subject: [PATCH 2/4] Fix incorrect lag due to trimming stream via XTRIM or XADD command (#13958) This PR fix the lag calculation by ensuring that when consumer group's last_id is behind the first entry, the consumer group's entries read is considered invalid and recalculated from the start of the stream Supplement to PR #13473 Close #13957 Signed-off-by: Ernesto Alejandro Santana Hidalgo --- src/t_stream.c | 5 ++++- tests/unit/type/stream-cgroups.tcl | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/t_stream.c b/src/t_stream.c index e4b8162c9..18a066aec 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -1695,7 +1695,10 @@ size_t streamReplyWithRange(client *c, stream *s, streamID *start, streamID *end while(streamIteratorGetID(&si,&id,&numfields)) { /* Update the group last_id if needed. */ if (group && streamCompareID(&id,&group->last_id) > 0) { - if (group->entries_read != SCG_INVALID_ENTRIES_READ && !streamRangeHasTombstones(s,&group->last_id,NULL)) { + if (group->entries_read != SCG_INVALID_ENTRIES_READ && + streamCompareID(&group->last_id, &s->first_id) >= 0 && + !streamRangeHasTombstones(s,&group->last_id,NULL)) + { /* A valid counter and no tombstones between the group's last-delivered-id * and the stream's last-generated-id mean we can increment the read counter * to keep tracking the group's progress. */ diff --git a/tests/unit/type/stream-cgroups.tcl b/tests/unit/type/stream-cgroups.tcl index 3a5c77b7e..ff4b4021e 100644 --- a/tests/unit/type/stream-cgroups.tcl +++ b/tests/unit/type/stream-cgroups.tcl @@ -1300,6 +1300,19 @@ start_server { assert_equal [dict get $group entries-read] 1 assert_equal [dict get $group lag] 1 + # When all the entries are read, the lag is always 0. + r XREADGROUP GROUP mygroup alice STREAMS x > + set reply [r XINFO STREAM x FULL] + set group [lindex [dict get $reply groups] 0] + assert_equal [dict get $group entries-read] 5 + assert_equal [dict get $group lag] 0 + + r XADD x 6-0 data f + set reply [r XINFO STREAM x FULL] + set group [lindex [dict get $reply groups] 0] + assert_equal [dict get $group entries-read] 5 + assert_equal [dict get $group lag] 1 + # When all the entries were deleted, the lag is always 0. r XTRIM x MAXLEN 0 set reply [r XINFO STREAM x FULL] From 9f99dd5f6d96c9914e7effafd625eb90181f6a53 Mon Sep 17 00:00:00 2001 From: Vitah Lin Date: Thu, 24 Apr 2025 09:36:45 +0800 Subject: [PATCH 3/4] Fix tls port update not reflected in CLUSTER SLOTS (#13966) ### Problem A previous PR (https://github.com/redis/redis/pull/13932) fixed the TCP port issue in CLUSTER SLOTS, but it seems the handling of the TLS port was overlooked. There is this comment in the `addNodeToNodeReply` function in the `cluster.c` file: ```c /* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */ addReplyLongLong(c, clusterNodeClientPort(node, shouldReturnTlsInfo())); addReplyBulkCBuffer(c, clusterNodeGetName(node), CLUSTER_NAMELEN); ``` ### Fixed This PR fixes the TLS port issue and adds relevant tests. --- src/config.c | 1 + tests/unit/cluster/announced-endpoints.tcl | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/config.c b/src/config.c index e33010276..b15f9090a 100644 --- a/src/config.c +++ b/src/config.c @@ -2688,6 +2688,7 @@ static int applyTLSPort(const char **err) { listener->bindaddr_count = server.bindaddr_count; listener->port = server.tls_port; listener->ct = connectionByType(CONN_TYPE_TLS); + clusterUpdateMyselfAnnouncedPorts(); if (changeListener(listener) == C_ERR) { *err = "Unable to listen on this port. Check server logs."; return 0; diff --git a/tests/unit/cluster/announced-endpoints.tcl b/tests/unit/cluster/announced-endpoints.tcl index 1eb40ac4b..a37ca58d1 100644 --- a/tests/unit/cluster/announced-endpoints.tcl +++ b/tests/unit/cluster/announced-endpoints.tcl @@ -49,12 +49,21 @@ start_cluster 2 2 {tags {external:skip cluster}} { } test "CONFIG SET port updates cluster-announced port" { + set count [expr [llength $::servers] + 1] # Get the original port and change to new_port - set orig_port [lindex [R 0 config get port] 1] + if {$::tls} { + set orig_port [lindex [R 0 config get tls-port] 1] + } else { + set orig_port [lindex [R 0 config get port] 1] + } assert {$orig_port != ""} + set new_port [find_available_port $orig_port $count] - set new_port [find_available_port $baseport $count] - R 0 config set port $new_port + if {$::tls} { + R 0 config set tls-port $new_port + } else { + R 0 config set port $new_port + } # Verify that the new port appears in the output of cluster slots wait_for_condition 50 100 { From bd3c1e1bd7049a879c2a3902aaca8745f18c044f Mon Sep 17 00:00:00 2001 From: Vitah Lin Date: Thu, 24 Apr 2025 10:50:35 +0800 Subject: [PATCH 4/4] Delete redundant declaration of handleDebugClusterCommand() (#13974) --- src/cluster.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cluster.h b/src/cluster.h index 225c3e6e5..9710e5d92 100644 --- a/src/cluster.h +++ b/src/cluster.h @@ -107,7 +107,6 @@ clusterNode *getMyClusterNode(void); char *getMyClusterId(void); int getClusterSize(void); int getMyShardSlotCount(void); -int handleDebugClusterCommand(client *c); int clusterNodePending(clusterNode *node); char **getClusterNodesList(size_t *numnodes); int clusterNodeIsMaster(clusterNode *n);