Commit b7f18015 authored by Marc Gravell's avatar Marc Gravell

include counters from GetOutstandingCount when reporting...

include counters from GetOutstandingCount when reporting WriteResult.TimeoutBeforeWrite; include a "what were you doing?" when reporting certain ProtocolFailure exceptions; also, make the IDE happier
parent 51445c78
...@@ -601,8 +601,10 @@ public async Task<string[]> GetSuggestionsAsync(string prefix, bool fuzzy = fals ...@@ -601,8 +601,10 @@ public async Task<string[]> GetSuggestionsAsync(string prefix, bool fuzzy = fals
/// <param name="query">The query to watch</param> /// <param name="query">The query to watch</param>
public AggregationResult Aggregate(AggregationRequest query) public AggregationResult Aggregate(AggregationRequest query)
{ {
var args = new List<object>(); var args = new List<object>
args.Add(_boxedIndexName); {
_boxedIndexName
};
query.SerializeRedisArgs(args); query.SerializeRedisArgs(args);
var resp = DbSync.Execute("FT.AGGREGATE", args); var resp = DbSync.Execute("FT.AGGREGATE", args);
...@@ -615,8 +617,10 @@ public AggregationResult Aggregate(AggregationRequest query) ...@@ -615,8 +617,10 @@ public AggregationResult Aggregate(AggregationRequest query)
/// <param name="query">The query to watch</param> /// <param name="query">The query to watch</param>
public async Task<AggregationResult> AggregateAsync(AggregationRequest query) public async Task<AggregationResult> AggregateAsync(AggregationRequest query)
{ {
var args = new List<object>(); var args = new List<object>
args.Add(_boxedIndexName); {
_boxedIndexName
};
query.SerializeRedisArgs(args); query.SerializeRedisArgs(args);
var resp = await _db.ExecuteAsync("FT.AGGREGATE", args).ConfigureAwait(false); var resp = await _db.ExecuteAsync("FT.AGGREGATE", args).ConfigureAwait(false);
......
...@@ -21,7 +21,7 @@ public enum FieldType ...@@ -21,7 +21,7 @@ public enum FieldType
public class Field public class Field
{ {
public String Name { get; } public string Name { get; }
public FieldType Type { get; } public FieldType Type { get; }
public bool Sortable { get; } public bool Sortable { get; }
public bool NoIndex { get; } public bool NoIndex { get; }
......
...@@ -302,7 +302,7 @@ public void KeyRename() ...@@ -302,7 +302,7 @@ public void KeyRename()
[Fact] [Fact]
public void KeyRestore() public void KeyRestore()
{ {
Byte[] value = new Byte[0]; byte[] value = new byte[0];
TimeSpan expiry = TimeSpan.FromSeconds(123); TimeSpan expiry = TimeSpan.FromSeconds(123);
wrapper.KeyRestore("key", value, expiry, CommandFlags.HighPriority); wrapper.KeyRestore("key", value, expiry, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyRestore("prefix:key", value, expiry, CommandFlags.HighPriority)); mock.Verify(_ => _.KeyRestore("prefix:key", value, expiry, CommandFlags.HighPriority));
......
...@@ -2066,8 +2066,20 @@ internal Exception GetException(WriteResult result, Message message, ServerEndPo ...@@ -2066,8 +2066,20 @@ internal Exception GetException(WriteResult result, Message message, ServerEndPo
case WriteResult.NoConnectionAvailable: case WriteResult.NoConnectionAvailable:
return ExceptionFactory.NoConnectionAvailable(IncludeDetailInExceptions, IncludePerformanceCountersInExceptions, message.Command, message, server, GetServerSnapshot()); return ExceptionFactory.NoConnectionAvailable(IncludeDetailInExceptions, IncludePerformanceCountersInExceptions, message.Command, message, server, GetServerSnapshot());
case WriteResult.TimeoutBeforeWrite: case WriteResult.TimeoutBeforeWrite:
string counters = null;
try
{
var bridge = server.GetBridge(message.Command, false);
if (bridge != null)
{
bridge.GetOutstandingCount(out var inst, out var qs, out var @in);
counters = $", inst={inst}, qs={qs}, in={@in}";
}
}
catch { }
return ExceptionFactory.Timeout(IncludeDetailInExceptions, "The timeout was reached before the message could be written to the output buffer, and it was not sent (" return ExceptionFactory.Timeout(IncludeDetailInExceptions, "The timeout was reached before the message could be written to the output buffer, and it was not sent ("
+ Format.ToString(TimeoutMilliseconds) + "ms)", message, server); + Format.ToString(TimeoutMilliseconds) + "ms" + counters + ")", message, server);
case WriteResult.WriteFailure: case WriteResult.WriteFailure:
default: default:
return ExceptionFactory.ConnectionFailure(IncludeDetailInExceptions, ConnectionFailureType.ProtocolFailure, "An unknown error occurred when writing the message", server); return ExceptionFactory.ConnectionFailure(IncludeDetailInExceptions, ConnectionFailureType.ProtocolFailure, "An unknown error occurred when writing the message", server);
......
...@@ -601,10 +601,10 @@ internal bool ComputeResult(PhysicalConnection connection, RawResult result) ...@@ -601,10 +601,10 @@ internal bool ComputeResult(PhysicalConnection connection, RawResult result)
} }
} }
internal void Fail(ConnectionFailureType failure, Exception innerException) internal void Fail(ConnectionFailureType failure, Exception innerException, string annotation)
{ {
PhysicalConnection.IdentifyFailureType(innerException, ref failure); PhysicalConnection.IdentifyFailureType(innerException, ref failure);
resultProcessor?.ConnectionFail(this, failure, innerException); resultProcessor?.ConnectionFail(this, failure, innerException, annotation);
} }
internal void SetException(Exception exception) internal void SetException(Exception exception)
...@@ -697,7 +697,7 @@ internal void WriteTo(PhysicalConnection physical) ...@@ -697,7 +697,7 @@ internal void WriteTo(PhysicalConnection physical)
catch (Exception ex) catch (Exception ex)
{ {
physical?.OnInternalError(ex); physical?.OnInternalError(ex);
Fail(ConnectionFailureType.InternalFailure, ex); Fail(ConnectionFailureType.InternalFailure, ex, null);
} }
} }
......
...@@ -194,7 +194,8 @@ internal void GetOutstandingCount(out int inst, out int qs, out int @in) ...@@ -194,7 +194,8 @@ internal void GetOutstandingCount(out int inst, out int qs, out int @in)
var tmp = physical; var tmp = physical;
if (tmp == null) if (tmp == null)
{ {
qs = @in = 0; qs = 0;
@in = -1;
} }
else else
{ {
...@@ -539,7 +540,7 @@ internal WriteResult WriteMessageTakingWriteLock(PhysicalConnection physical, Me ...@@ -539,7 +540,7 @@ internal WriteResult WriteMessageTakingWriteLock(PhysicalConnection physical, Me
// we screwed up; abort; note that WriteMessageToServer already // we screwed up; abort; note that WriteMessageToServer already
// killed the underlying connection // killed the underlying connection
Trace("Unable to write to server"); Trace("Unable to write to server");
next.Fail(ConnectionFailureType.ProtocolFailure, null); next.Fail(ConnectionFailureType.ProtocolFailure, null, "failure before write: " + result.ToString());
CompleteSyncOrAsync(next); CompleteSyncOrAsync(next);
return result; return result;
} }
...@@ -739,7 +740,7 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne ...@@ -739,7 +740,7 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne
catch (RedisCommandException ex) catch (RedisCommandException ex)
{ {
Trace("Write failed: " + ex.Message); Trace("Write failed: " + ex.Message);
message.Fail(ConnectionFailureType.InternalFailure, ex); message.Fail(ConnectionFailureType.InternalFailure, ex, null);
CompleteSyncOrAsync(message); CompleteSyncOrAsync(message);
// this failed without actually writing; we're OK with that... unless there's a transaction // this failed without actually writing; we're OK with that... unless there's a transaction
...@@ -754,7 +755,7 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne ...@@ -754,7 +755,7 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne
catch (Exception ex) catch (Exception ex)
{ {
Trace("Write failed: " + ex.Message); Trace("Write failed: " + ex.Message);
message.Fail(ConnectionFailureType.InternalFailure, ex); message.Fail(ConnectionFailureType.InternalFailure, ex, null);
CompleteSyncOrAsync(message); CompleteSyncOrAsync(message);
// we're not sure *what* happened here; probably an IOException; kill the connection // we're not sure *what* happened here; probably an IOException; kill the connection
......
...@@ -1030,7 +1030,7 @@ private static void WriteUnified(PipeWriter writer, long value) ...@@ -1030,7 +1030,7 @@ private static void WriteUnified(PipeWriter writer, long value)
writer.Advance(bytes); writer.Advance(bytes);
} }
internal int GetAvailableInboundBytes() => _socket?.Available ?? 0; internal int GetAvailableInboundBytes() => _socket?.Available ?? -1;
private RemoteCertificateValidationCallback GetAmbientIssuerCertificateCallback() private RemoteCertificateValidationCallback GetAmbientIssuerCertificateCallback()
{ {
......
...@@ -98,7 +98,7 @@ private void FailNoServer(List<Message> messages) ...@@ -98,7 +98,7 @@ private void FailNoServer(List<Message> messages)
var completion = multiplexer.UnprocessableCompletionManager; var completion = multiplexer.UnprocessableCompletionManager;
foreach(var msg in messages) foreach(var msg in messages)
{ {
msg.Fail(ConnectionFailureType.UnableToResolvePhysicalConnection, null); msg.Fail(ConnectionFailureType.UnableToResolvePhysicalConnection, null, "unable to write batch");
completion.CompleteSyncOrAsync(msg); completion.CompleteSyncOrAsync(msg);
} }
} }
......
...@@ -455,7 +455,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes ...@@ -455,7 +455,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
// the pending tasks // the pending tasks
foreach (var op in wrapped) foreach (var op in wrapped)
{ {
op.Wrapped.Fail(ConnectionFailureType.ProtocolFailure, null); op.Wrapped.Fail(ConnectionFailureType.ProtocolFailure, null, "transaction failure");
bridge.CompleteSyncOrAsync(op.Wrapped); bridge.CompleteSyncOrAsync(op.Wrapped);
} }
} }
......
...@@ -137,12 +137,14 @@ public static readonly HashEntryArrayProcessor ...@@ -137,12 +137,14 @@ public static readonly HashEntryArrayProcessor
ASK = Encoding.UTF8.GetBytes("ASK "), ASK = Encoding.UTF8.GetBytes("ASK "),
NOAUTH = Encoding.UTF8.GetBytes("NOAUTH "); NOAUTH = Encoding.UTF8.GetBytes("NOAUTH ");
public void ConnectionFail(Message message, ConnectionFailureType fail, Exception innerException) public void ConnectionFail(Message message, ConnectionFailureType fail, Exception innerException, string annotation)
{ {
PhysicalConnection.IdentifyFailureType(innerException, ref fail); PhysicalConnection.IdentifyFailureType(innerException, ref fail);
string exMessage = fail.ToString() + (message == null ? "" : (" on " + ( string exMessage = fail.ToString() + (message == null ? "" : (" on " + (
fail == ConnectionFailureType.ProtocolFailure ? message.ToString() : message.CommandAndKey))); fail == ConnectionFailureType.ProtocolFailure ? message.ToString() : message.CommandAndKey)));
if (!string.IsNullOrWhiteSpace(annotation)) exMessage += ", " + annotation;
var ex = innerException == null ? new RedisConnectionException(fail, exMessage) var ex = innerException == null ? new RedisConnectionException(fail, exMessage)
: new RedisConnectionException(fail, exMessage, innerException); : new RedisConnectionException(fail, exMessage, innerException);
SetException(message, ex); SetException(message, ex);
...@@ -1919,8 +1921,7 @@ private sealed class SentinelArrayOfArraysProcessor : ResultProcessor<KeyValuePa ...@@ -1919,8 +1921,7 @@ private sealed class SentinelArrayOfArraysProcessor : ResultProcessor<KeyValuePa
{ {
protected override bool SetResultCore(PhysicalConnection connection, Message message, RawResult result) protected override bool SetResultCore(PhysicalConnection connection, Message message, RawResult result)
{ {
var innerProcessor = StringPairInterleaved as StringPairInterleavedProcessor; if (!(StringPairInterleaved is StringPairInterleavedProcessor innerProcessor))
if (innerProcessor == null)
{ {
return false; return false;
} }
......
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