Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test:
$(MAKE) CFLAGS="-m32" LDFLAGS="-m32"

valgrind:
$(MAKE) OPTIMIZATION="-O0" MALLOC="libc"
$(MAKE) OPTIMIZATION="-O3" MALLOC="libc"

helgrind:
$(MAKE) OPTIMIZATION="-O0" MALLOC="libc" CFLAGS="-D__ATOMIC_VAR_FORCE_SYNC_MACROS"
$(MAKE) OPTIMIZATION="-O3" MALLOC="libc" CFLAGS="-D__ATOMIC_VAR_FORCE_SYNC_MACROS"
8 changes: 8 additions & 0 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ int resetCluster(redisCluster *cluster) {
freeClusterNodes(cluster);
cluster->slots_map = raxNew();
cluster->nodes_by_name = raxNew();
cluster->master_names = NULL;
cluster->nodes = listCreate();
if (!cluster->slots_map) return 0;
if (!cluster->nodes) return 0;
Expand Down Expand Up @@ -888,6 +889,13 @@ int updateCluster(redisCluster *cluster) {
}
cluster->is_updating = 0;
cluster->update_required = 0;
/* Call once to refresh the master_names list */
if (clusterGetMasterNames(cluster) == NULL) {
proxyLogErr("Failed to update master names after fetching cluster configuration! (thread: %d)",
cluster->thread_id);
status = CLUSTER_RECONFIG_ERR;
goto final;
}
proxyLogDebug("Reprocessing cluster requests (thread: %d)",
cluster->thread_id);
while (raxNext(&iter)) {
Expand Down
2 changes: 1 addition & 1 deletion src/reply_order.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int appendUnorderedRepliesToBuffer(client *c) {
uint64_t req_id = ntohu64(*((uint64_t *)iter.key));
if (req_id == c->min_reply_id) {
sds reply = (sds) iter.data;
c->obuf = sdscat(c->obuf, reply);
c->obuf = sdscatsds(c->obuf, reply);
c->min_reply_id++;
count++;
if (raxRemove(c->unordered_replies, iter.key, iter.key_len, NULL)){
Expand Down
2 changes: 1 addition & 1 deletion src/sds.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#define __SDS_H

#define SDS_MAX_PREALLOC (1024*1024)
const char *SDS_NOINIT;
extern const char *SDS_NOINIT;

#include <sys/types.h>
#include <stdarg.h>
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define REDIS_CLUSTER_PROXY_VERSION "999.999.999"
#define REDIS_CLUSTER_PROXY_VERSION "1.0.1"
31 changes: 30 additions & 1 deletion test/tests/proxy_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'threads' => 8,
#'max-clients' => 10000
}
conf.each{|opt, val|
conf.each{|opt, val|
reply = $main_proxy.proxy('config', 'get', opt.to_s)
assert_not_redis_err(reply)
assert(reply.is_a?(Array), "Expected array reply, got #{reply.class}")
Expand All @@ -22,3 +22,32 @@
log = File.read $main_proxy.logfile
assert_not_nil(log[msg], "Could not find logged message in proxy's log")
end

test "PROXY CLUSTER INFO" do
reply = $main_proxy.proxy('cluster', 'info')
assert_not_redis_err(reply)
assert(reply.is_a?(Array), "Expected array reply, got #{reply.class}")
assert(reply[0..4] == ["status", "updated", "connection", "shared", "nodes"], "Got unexpected reply: #{reply}")
reply[5].each{ |node|
_, name, _, ip, _, port, _, slots, _, replicas, _, connected = node
assert(ip == "127.0.0.1", "unexpected ip #{ip}")
assert([18000, 18001, 18002, 18003, 18004, 18005].include?(port), "unexpected port #{port}")
assert([5461, 5462].include?(slots), "unexpected slots #{slots}")
assert(replicas == 1, "replicas of #{replicas} != 1")
assert(connected == 1, "connected of #{connected} != 1")
}
end

test "PROXY CLUSTER UPDATE" do
info_before = $main_proxy.proxy('cluster', 'info')
assert_not_redis_err(info_before)

update_reply = $main_proxy.proxy('cluster', 'update')
assert_not_redis_err(update_reply)

info_after = $main_proxy.proxy('cluster', 'info')
assert_not_redis_err(info_after)

assert(info_before == info_after, "cluster info before update != cluster info after update.\n #{info_before} != #{info_after}")

end