Commit 15898d28 authored by Hrishikesh Pathak's avatar Hrishikesh Pathak

Surface better error instead of MOVED errors during network disconnects in redis clusters

parent a194c28d
......@@ -140,7 +140,8 @@ public virtual bool SetResult(PhysicalConnection connection, Message message, Ra
var bridge = connection.Bridge;
var server = bridge.ServerEndPoint;
bool log = !message.IsInternalCall;
bool isMoved = result.AssertStarts(MOVED);
bool isMoved = result.AssertStarts(MOVED);
string err = string.Empty;
if (isMoved || result.AssertStarts(ASK))
{
message.SetResponseReceived();
......@@ -151,21 +152,29 @@ public virtual bool SetResult(PhysicalConnection connection, Message message, Ra
EndPoint endpoint;
if (Format.TryParseInt32(parts[1], out hashSlot) &&
(endpoint = Format.TryParseEndPoint(parts[2])) != null)
{
{
// no point sending back to same server, and no point sending to a dead server
if (!Equals(server.EndPoint, endpoint))
{
if (bridge.Multiplexer.TryResend(hashSlot, message, endpoint, isMoved))
{
connection.Multiplexer.Trace(message.Command + " re-issued to " + endpoint, isMoved ? "MOVED" : "ASK");
return false;
{
if (bridge.Multiplexer.TryResend(hashSlot, message, endpoint, isMoved))
{
connection.Multiplexer.Trace(message.Command + " re-issued to " + endpoint, isMoved ? "MOVED" : "ASK");
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)
{
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