Commit d34701c8 authored by Marc Gravell's avatar Marc Gravell

Make `ResponseTimeout` a separate configuration option to `SyncTimeout`;...

Make `ResponseTimeout` a separate configuration option to `SyncTimeout`; expose the `origin` on failure messages
parent a158fa85
...@@ -9,7 +9,7 @@ public class Issue182 : TestBase ...@@ -9,7 +9,7 @@ public class Issue182 : TestBase
{ {
protected override string GetConfiguration() protected override string GetConfiguration()
{ {
return "127.0.0.1:6379,syncTimeout=10000"; return "127.0.0.1:6379,responseTimeout=10000";
} }
[Test] [Test]
public void SetMembers() public void SetMembers()
......
...@@ -73,7 +73,7 @@ internal static void Unknown(string key) ...@@ -73,7 +73,7 @@ internal static void Unknown(string key)
TieBreaker = "tiebreaker", WriteBuffer = "writeBuffer", Ssl = "ssl", SslHost = "sslHost", TieBreaker = "tiebreaker", WriteBuffer = "writeBuffer", Ssl = "ssl", SslHost = "sslHost",
ConfigChannel = "configChannel", AbortOnConnectFail = "abortConnect", ResolveDns = "resolveDns", ConfigChannel = "configChannel", AbortOnConnectFail = "abortConnect", ResolveDns = "resolveDns",
ChannelPrefix = "channelPrefix", Proxy = "proxy", ConnectRetry = "connectRetry", ChannelPrefix = "channelPrefix", Proxy = "proxy", ConnectRetry = "connectRetry",
ConfigCheckSeconds = "configCheckSeconds"; ConfigCheckSeconds = "configCheckSeconds", ResponseTimeout = "responseTimeout";
private static readonly Dictionary<string, string> normalizedOptions = new[] private static readonly Dictionary<string, string> normalizedOptions = new[]
{ {
AllowAdmin, SyncTimeout, AllowAdmin, SyncTimeout,
...@@ -107,7 +107,7 @@ public static string TryNormalize(string value) ...@@ -107,7 +107,7 @@ public static string TryNormalize(string value)
private Version defaultVersion; private Version defaultVersion;
private int? keepAlive, syncTimeout, connectTimeout, writeBuffer, connectRetry, configCheckSeconds; private int? keepAlive, syncTimeout, connectTimeout, responseTimeout, writeBuffer, connectRetry, configCheckSeconds;
private Proxy? proxy; private Proxy? proxy;
...@@ -245,10 +245,16 @@ public CommandMap CommandMap ...@@ -245,10 +245,16 @@ public CommandMap CommandMap
public string SslHost { get { return sslHost; } set { sslHost = value; } } public string SslHost { get { return sslHost; } set { sslHost = value; } }
/// <summary> /// <summary>
/// Specifies the time in milliseconds that the system should allow for synchronous operations /// Specifies the time in milliseconds that the system should allow for synchronous operations (defaults to 1 second)
/// </summary> /// </summary>
public int SyncTimeout { get { return syncTimeout.GetValueOrDefault(1000); } set { syncTimeout = value; } } public int SyncTimeout { get { return syncTimeout.GetValueOrDefault(1000); } set { syncTimeout = value; } }
/// <summary>
/// Specifies the time in milliseconds that the system should allow for responses before concluding that the socket is unhealthy
/// (defaults to SyncTimeout)
/// </summary>
public int ResponseTimeout { get { return responseTimeout ?? SyncTimeout; } set { responseTimeout = value; } }
/// <summary> /// <summary>
/// Tie-breaker used to choose between masters (must match the endpoint exactly) /// Tie-breaker used to choose between masters (must match the endpoint exactly)
/// </summary> /// </summary>
...@@ -320,7 +326,8 @@ public ConfigurationOptions Clone() ...@@ -320,7 +326,8 @@ public ConfigurationOptions Clone()
ChannelPrefix = ChannelPrefix.Clone(), ChannelPrefix = ChannelPrefix.Clone(),
SocketManager = SocketManager, SocketManager = SocketManager,
connectRetry = connectRetry, connectRetry = connectRetry,
configCheckSeconds = configCheckSeconds configCheckSeconds = configCheckSeconds,
responseTimeout = responseTimeout
}; };
foreach (var item in endpoints) foreach (var item in endpoints)
options.endpoints.Add(item); options.endpoints.Add(item);
...@@ -365,6 +372,7 @@ public override string ToString() ...@@ -365,6 +372,7 @@ public override string ToString()
Append(sb, OptionKeys.ConnectRetry, connectRetry); Append(sb, OptionKeys.ConnectRetry, connectRetry);
Append(sb, OptionKeys.Proxy, proxy); Append(sb, OptionKeys.Proxy, proxy);
Append(sb, OptionKeys.ConfigCheckSeconds, configCheckSeconds); Append(sb, OptionKeys.ConfigCheckSeconds, configCheckSeconds);
Append(sb, OptionKeys.ResponseTimeout, responseTimeout);
if (commandMap != null) commandMap.AppendDeltas(sb); if (commandMap != null) commandMap.AppendDeltas(sb);
return sb.ToString(); return sb.ToString();
} }
...@@ -557,6 +565,9 @@ private void DoParse(string configuration, bool ignoreUnknown) ...@@ -557,6 +565,9 @@ private void DoParse(string configuration, bool ignoreUnknown)
case OptionKeys.Proxy: case OptionKeys.Proxy:
Proxy = OptionKeys.ParseProxy(key, value); Proxy = OptionKeys.ParseProxy(key, value);
break; break;
case OptionKeys.ResponseTimeout:
ResponseTimeout = OptionKeys.ParseInt32(key, value, minValue: 1);
break;
default: default:
if (!string.IsNullOrEmpty(key) && key[0] == '$') if (!string.IsNullOrEmpty(key) && key[0] == '$')
{ {
......
...@@ -178,6 +178,7 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception ...@@ -178,6 +178,7 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
int unansweredRead = Thread.VolatileRead(ref firstUnansweredWriteTickCount); int unansweredRead = Thread.VolatileRead(ref firstUnansweredWriteTickCount);
string message = failureType + " on " + Format.ToString(bridge.ServerEndPoint.EndPoint) + "/" + connectionType string message = failureType + " on " + Format.ToString(bridge.ServerEndPoint.EndPoint) + "/" + connectionType
+ ", origin: " + origin
+ ", input-buffer: " + ioBufferBytes + ", outstanding: " + GetSentAwaitingResponseCount() + ", input-buffer: " + ioBufferBytes + ", outstanding: " + GetSentAwaitingResponseCount()
+ ", last-read: " + unchecked(now - lastRead) / 1000 + "s ago, last-write: " + unchecked(now - lastWrite) / 1000 + "s ago" + ", last-read: " + unchecked(now - lastRead) / 1000 + "s ago, last-write: " + unchecked(now - lastWrite) / 1000 + "s ago"
+ ", unanswered-write: " + unchecked(now - unansweredRead) / 1000 + "s ago" + ", unanswered-write: " + unchecked(now - unansweredRead) / 1000 + "s ago"
...@@ -993,7 +994,7 @@ public void CheckForStaleConnection() ...@@ -993,7 +994,7 @@ public void CheckForStaleConnection()
int now = Environment.TickCount; int now = Environment.TickCount;
if (firstUnansweredWrite != 0 && (now - firstUnansweredWrite) > this.multiplexer.RawConfig.SyncTimeout) if (firstUnansweredWrite != 0 && (now - firstUnansweredWrite) > this.multiplexer.RawConfig.ResponseTimeout)
{ {
this.RecordConnectionFailed(ConnectionFailureType.SocketFailure, origin: "CheckForStaleConnection"); this.RecordConnectionFailed(ConnectionFailureType.SocketFailure, origin: "CheckForStaleConnection");
} }
......
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