Commit 9dc6dd2d authored by Nick Craver's avatar Nick Craver

Update MOVED exception to account for ComandFlags.NoRedirect

Also fixes tests that go along with (failing previously due to a message change before this one).
parent 8c54c6b4
...@@ -162,15 +162,8 @@ public void IntentionalWrongServer() ...@@ -162,15 +162,8 @@ public void IntentionalWrongServer()
string b = conn.GetServer(node.EndPoint).StringGet(db.Database, key); string b = conn.GetServer(node.EndPoint).StringGet(db.Database, key);
Assert.Equal(value, b); // wrong master, allow redirect Assert.Equal(value, b); // wrong master, allow redirect
try var ex = Assert.Throws<RedisServerException>(() => conn.GetServer(node.EndPoint).StringGet(db.Database, key, CommandFlags.NoRedirect));
{ Assert.StartsWith($"Key has MOVED from Endpoint {rightMasterNode.EndPoint} and hashslot {slot}", ex.Message);
string c = conn.GetServer(node.EndPoint).StringGet(db.Database, key, CommandFlags.NoRedirect);
Assert.True(false, "wrong master, no redirect");
}
catch (RedisServerException ex)
{
Assert.True("MOVED " + slot + " " + rightMasterNode.EndPoint == ex.Message, "wrong master, no redirect");
}
} }
node = config.Nodes.FirstOrDefault(x => x.IsSlave && x.ParentNodeId == rightMasterNode.NodeId); node = config.Nodes.FirstOrDefault(x => x.IsSlave && x.ParentNodeId == rightMasterNode.NodeId);
...@@ -187,16 +180,9 @@ public void IntentionalWrongServer() ...@@ -187,16 +180,9 @@ public void IntentionalWrongServer()
{ {
string e = conn.GetServer(node.EndPoint).StringGet(db.Database, key); string e = conn.GetServer(node.EndPoint).StringGet(db.Database, key);
Assert.Equal(value, e); // wrong slave, allow redirect Assert.Equal(value, e); // wrong slave, allow redirect
try var ex = Assert.Throws<RedisServerException>(() => conn.GetServer(node.EndPoint).StringGet(db.Database, key, CommandFlags.NoRedirect));
{ Assert.StartsWith($"Key has MOVED from Endpoint {rightMasterNode.EndPoint} and hashslot {slot}", ex.Message);
string f = conn.GetServer(node.EndPoint).StringGet(db.Database, key, CommandFlags.NoRedirect);
Assert.True(false, "wrong slave, no redirect");
}
catch (RedisServerException ex)
{
Assert.True("MOVED " + slot + " " + rightMasterNode.EndPoint == ex.Message, "wrong slave, no redirect");
}
} }
#endif #endif
......
...@@ -175,7 +175,14 @@ public virtual bool SetResult(PhysicalConnection connection, Message message, Ra ...@@ -175,7 +175,14 @@ public virtual bool SetResult(PhysicalConnection connection, Message message, Ra
} }
else 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 (isMoved && (message.Flags & CommandFlags.NoRedirect) != 0)
{
err = $"Key has MOVED from Endpoint {endpoint} and hashslot {hashSlot} but CommandFlags.NoRedirect was specified - redirect not followed. ";
}
else
{
err = $"Endpoint {endpoint} serving hashslot {hashSlot} 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. ";
}
#if FEATURE_PERFCOUNTER #if FEATURE_PERFCOUNTER
err += ConnectionMultiplexer.GetThreadPoolAndCPUSummary(bridge.Multiplexer.IncludePerformanceCountersInExceptions); err += ConnectionMultiplexer.GetThreadPoolAndCPUSummary(bridge.Multiplexer.IncludePerformanceCountersInExceptions);
#endif #endif
......
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