Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return re-connection failures immediately #159

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion hircluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,10 @@ redisContext *ctx_get_by_node(redisClusterContext *cc, redisClusterNode *node) {
c = node->con;
if (c != NULL) {
if (c->err) {
redisReconnect(c);
if (redisReconnect(c) != REDIS_OK) {
__redisClusterSetError(cc, c->err, c->errstr);
return NULL;
}

if (cc->ssl && cc->ssl_init_fn(c, cc->ssl) != REDIS_OK) {
__redisClusterSetError(cc, c->err, c->errstr);
Comment on lines -1905 to 1911
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw this too but I thought ssl_init_fn is supposed to handle a connection which failed to reconnect.

It seems cleaner to return ASAP though, but I'd like to understand the consequences better.

Expand Down
20 changes: 1 addition & 19 deletions tests/scripts/reconnect-failure-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,6 @@ EXPECT CONNECT
EXPECT ["SET", "bar", "initial"]
SEND +OK

# A reconnect failure triggers a search for an available node
EXPECT ["PING"]
SEND +PONG
EXPECT ["SET", "foo", "second"]
SEND -MOVED 12182 127.0.0.1:7402
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, looking at the commits one by one explains it. :)

Legacy: After N failed reconnect attempts, it sends the command to a random node and gets a redirect (after PING), then slot map update? Then the same thing is repeated M times. I don't get it exactly. Is maxretry = N or maxretry = M?


# Since maxretry=2 a MOVED triggers a slotmap update (no slotmap change in this test)
EXPECT CONNECT
EXPECT ["CLUSTER", "SLOTS"]
SEND [[0, 6000, ["127.0.0.1", 7401, "nodeid1"]],[6001, 16383, ["127.0.0.1", 7402, "nodeid2"]]]
EXPECT CLOSE

# A reconnect failure triggers a new search for an available node
EXPECT ["PING"]
SEND +PONG

# Max retry exhausted

EXPECT CLOSE
EOF
server1=$!
Expand Down Expand Up @@ -95,7 +77,7 @@ fi
expected="OK
OK
error: Server closed the connection
error: too many cluster retries"
error: Connection refused"

cmp "$testname.out" <(echo "$expected") || exit 99

Expand Down