Commit 5688bc11 authored by Marc Gravell's avatar Marc Gravell Committed by GitHub

Merge pull request #451 from hrishi18pathak/SEClusterConfigBugFix

Surface better error instead of MOVED errors during a network disconnect in redis clusters 
parents 2fd4b123 7d74d187
...@@ -140,7 +140,8 @@ public virtual bool SetResult(PhysicalConnection connection, Message message, Ra ...@@ -140,7 +140,8 @@ public virtual bool SetResult(PhysicalConnection connection, Message message, Ra
var bridge = connection.Bridge; var bridge = connection.Bridge;
var server = bridge.ServerEndPoint; var server = bridge.ServerEndPoint;
bool log = !message.IsInternalCall; bool log = !message.IsInternalCall;
bool isMoved = result.AssertStarts(MOVED); bool isMoved = result.AssertStarts(MOVED);
string err = string.Empty;
if (isMoved || result.AssertStarts(ASK)) if (isMoved || result.AssertStarts(ASK))
{ {
message.SetResponseReceived(); message.SetResponseReceived();
...@@ -151,21 +152,29 @@ public virtual bool SetResult(PhysicalConnection connection, Message message, Ra ...@@ -151,21 +152,29 @@ public virtual bool SetResult(PhysicalConnection connection, Message message, Ra
EndPoint endpoint; EndPoint endpoint;
if (Format.TryParseInt32(parts[1], out hashSlot) && if (Format.TryParseInt32(parts[1], out hashSlot) &&
(endpoint = Format.TryParseEndPoint(parts[2])) != null) (endpoint = Format.TryParseEndPoint(parts[2])) != null)
{ {
// no point sending back to same server, and no point sending to a dead server // no point sending back to same server, and no point sending to a dead server
if (!Equals(server.EndPoint, endpoint)) if (!Equals(server.EndPoint, endpoint))
{ {
if (bridge.Multiplexer.TryResend(hashSlot, message, endpoint, isMoved)) if (bridge.Multiplexer.TryResend(hashSlot, message, endpoint, isMoved))
{ {
connection.Multiplexer.Trace(message.Command + " re-issued to " + endpoint, isMoved ? "MOVED" : "ASK"); connection.Multiplexer.Trace(message.Command + " re-issued to " + endpoint, isMoved ? "MOVED" : "ASK");
return false; return false;
}
else
{
err = string.Format("Endpoint {0} serving hashslot {1} is not reachable at this point of time. Please check connectTimeout value. If it is low, try increasing it to give the ConnectionMultiplexer a chance to recover from the network disconnect.", endpoint, hashSlot);
} }
} }
} }
}
if (string.IsNullOrWhiteSpace(err))
{
err = result.GetString();
} }
string err = result.GetString();
if (log) if (log)
{ {
bridge.Multiplexer.OnErrorMessage(server.EndPoint, err); bridge.Multiplexer.OnErrorMessage(server.EndPoint, err);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment