Skip to content

Commit aa6d06a

Browse files
domrodDominique Rodrigues
andauthored
Apply several pull requests from project (#1)
* Apply merge request RedisLabs#98 From RedisLabs#98 * Apply Merge Request RedisLabs#82 From RedisLabs#82 * Apply Merge Request RedisLabs#67 From RedisLabs#67 * Set optimization in makefile to -O3 * Add a Dockerfile for tests and set a version Co-authored-by: Dominique Rodrigues <[email protected]>
1 parent ac83840 commit aa6d06a

File tree

6 files changed

+43
-6
lines changed

6 files changed

+43
-6
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test:
1919
$(MAKE) CFLAGS="-m32" LDFLAGS="-m32"
2020

2121
valgrind:
22-
$(MAKE) OPTIMIZATION="-O0" MALLOC="libc"
22+
$(MAKE) OPTIMIZATION="-O3" MALLOC="libc"
2323

2424
helgrind:
25-
$(MAKE) OPTIMIZATION="-O0" MALLOC="libc" CFLAGS="-D__ATOMIC_VAR_FORCE_SYNC_MACROS"
25+
$(MAKE) OPTIMIZATION="-O3" MALLOC="libc" CFLAGS="-D__ATOMIC_VAR_FORCE_SYNC_MACROS"

src/cluster.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ int resetCluster(redisCluster *cluster) {
280280
freeClusterNodes(cluster);
281281
cluster->slots_map = raxNew();
282282
cluster->nodes_by_name = raxNew();
283+
cluster->master_names = NULL;
283284
cluster->nodes = listCreate();
284285
if (!cluster->slots_map) return 0;
285286
if (!cluster->nodes) return 0;
@@ -888,6 +889,13 @@ int updateCluster(redisCluster *cluster) {
888889
}
889890
cluster->is_updating = 0;
890891
cluster->update_required = 0;
892+
/* Call once to refresh the master_names list */
893+
if (clusterGetMasterNames(cluster) == NULL) {
894+
proxyLogErr("Failed to update master names after fetching cluster configuration! (thread: %d)",
895+
cluster->thread_id);
896+
status = CLUSTER_RECONFIG_ERR;
897+
goto final;
898+
}
891899
proxyLogDebug("Reprocessing cluster requests (thread: %d)",
892900
cluster->thread_id);
893901
while (raxNext(&iter)) {

src/reply_order.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int appendUnorderedRepliesToBuffer(client *c) {
4949
uint64_t req_id = ntohu64(*((uint64_t *)iter.key));
5050
if (req_id == c->min_reply_id) {
5151
sds reply = (sds) iter.data;
52-
c->obuf = sdscat(c->obuf, reply);
52+
c->obuf = sdscatsds(c->obuf, reply);
5353
c->min_reply_id++;
5454
count++;
5555
if (raxRemove(c->unordered_replies, iter.key, iter.key_len, NULL)){

src/sds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#define __SDS_H
3535

3636
#define SDS_MAX_PREALLOC (1024*1024)
37-
const char *SDS_NOINIT;
37+
extern const char *SDS_NOINIT;
3838

3939
#include <sys/types.h>
4040
#include <stdarg.h>

src/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define REDIS_CLUSTER_PROXY_VERSION "999.999.999"
1+
#define REDIS_CLUSTER_PROXY_VERSION "1.0.1"

test/tests/proxy_command.rb

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
'threads' => 8,
66
#'max-clients' => 10000
77
}
8-
conf.each{|opt, val|
8+
conf.each{|opt, val|
99
reply = $main_proxy.proxy('config', 'get', opt.to_s)
1010
assert_not_redis_err(reply)
1111
assert(reply.is_a?(Array), "Expected array reply, got #{reply.class}")
@@ -22,3 +22,32 @@
2222
log = File.read $main_proxy.logfile
2323
assert_not_nil(log[msg], "Could not find logged message in proxy's log")
2424
end
25+
26+
test "PROXY CLUSTER INFO" do
27+
reply = $main_proxy.proxy('cluster', 'info')
28+
assert_not_redis_err(reply)
29+
assert(reply.is_a?(Array), "Expected array reply, got #{reply.class}")
30+
assert(reply[0..4] == ["status", "updated", "connection", "shared", "nodes"], "Got unexpected reply: #{reply}")
31+
reply[5].each{ |node|
32+
_, name, _, ip, _, port, _, slots, _, replicas, _, connected = node
33+
assert(ip == "127.0.0.1", "unexpected ip #{ip}")
34+
assert([18000, 18001, 18002, 18003, 18004, 18005].include?(port), "unexpected port #{port}")
35+
assert([5461, 5462].include?(slots), "unexpected slots #{slots}")
36+
assert(replicas == 1, "replicas of #{replicas} != 1")
37+
assert(connected == 1, "connected of #{connected} != 1")
38+
}
39+
end
40+
41+
test "PROXY CLUSTER UPDATE" do
42+
info_before = $main_proxy.proxy('cluster', 'info')
43+
assert_not_redis_err(info_before)
44+
45+
update_reply = $main_proxy.proxy('cluster', 'update')
46+
assert_not_redis_err(update_reply)
47+
48+
info_after = $main_proxy.proxy('cluster', 'info')
49+
assert_not_redis_err(info_after)
50+
51+
assert(info_before == info_after, "cluster info before update != cluster info after update.\n #{info_before} != #{info_after}")
52+
53+
end

0 commit comments

Comments
 (0)