Commit 4cd87860 authored by Marc Gravell's avatar Marc Gravell

even moar TransactionLog usefulness

parent 85165681
...@@ -261,7 +261,7 @@ protected IServer GetAnyMaster(ConnectionMultiplexer muxer) ...@@ -261,7 +261,7 @@ protected IServer GetAnyMaster(ConnectionMultiplexer muxer)
muxer.ConnectionFailed += OnConnectionFailed; muxer.ConnectionFailed += OnConnectionFailed;
muxer.MessageFaulted += (msg, ex, origin) => Writer?.WriteLine($"Faulted from '{origin}': '{msg}' - '{(ex == null ? "(null)" : ex.Message)}'"); muxer.MessageFaulted += (msg, ex, origin) => Writer?.WriteLine($"Faulted from '{origin}': '{msg}' - '{(ex == null ? "(null)" : ex.Message)}'");
muxer.Connecting += (e, t) => Writer.WriteLine($"Connecting to {Format.ToString(e)} as {t}"); muxer.Connecting += (e, t) => Writer.WriteLine($"Connecting to {Format.ToString(e)} as {t}");
muxer.TransactionLog += msg => Writer.WriteLine("tran: " + msg); muxer.TransactionLog += msg => { lock (Writer) { Writer.WriteLine("tran: " + msg); } };
muxer.Resurrecting += (e, t) => Writer.WriteLine($"Resurrecting {Format.ToString(e)} as {t}"); muxer.Resurrecting += (e, t) => Writer.WriteLine($"Resurrecting {Format.ToString(e)} as {t}");
muxer.Closing += complete => Writer.WriteLine(complete ? "Closed" : "Closing..."); muxer.Closing += complete => Writer.WriteLine(complete ? "Closed" : "Closing...");
return muxer; return muxer;
......
...@@ -162,6 +162,9 @@ protected override void WriteImpl(PhysicalConnection physical) ...@@ -162,6 +162,9 @@ protected override void WriteImpl(PhysicalConnection physical)
Wrapped.SetRequestSent(); Wrapped.SetRequestSent();
} }
public override int ArgCount => Wrapped.ArgCount; public override int ArgCount => Wrapped.ArgCount;
public override string CommandAndKey => Wrapped.CommandAndKey;
public override int GetHashSlot(ServerSelectionStrategy serverSelectionStrategy)
=> Wrapped.GetHashSlot(serverSelectionStrategy);
} }
private class QueuedProcessor : ResultProcessor<bool> private class QueuedProcessor : ResultProcessor<bool>
...@@ -174,6 +177,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes ...@@ -174,6 +177,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
{ {
if (message is QueuedMessage q) if (message is QueuedMessage q)
{ {
connection?.BridgeCouldBeNull?.Multiplexer?.OnTransactionLog($"observed QUEUED for " + q.Wrapped?.CommandAndKey);
q.WasQueued = true; q.WasQueued = true;
} }
return true; return true;
...@@ -318,7 +322,6 @@ public IEnumerable<Message> GetMessages(PhysicalConnection connection) ...@@ -318,7 +322,6 @@ public IEnumerable<Message> GetMessages(PhysicalConnection connection)
} }
multiplexer.OnTransactionLog($"issued {InnerOperations.Length} operations"); multiplexer.OnTransactionLog($"issued {InnerOperations.Length} operations");
if (explicitCheckForQueued && lastBox != null) if (explicitCheckForQueued && lastBox != null)
{ {
multiplexer.OnTransactionLog($"checking conditions in the *late* path"); multiplexer.OnTransactionLog($"checking conditions in the *late* path");
...@@ -373,7 +376,7 @@ public IEnumerable<Message> GetMessages(PhysicalConnection connection) ...@@ -373,7 +376,7 @@ public IEnumerable<Message> GetMessages(PhysicalConnection connection)
} }
} }
connection.Trace("End of transaction: " + Command); connection.Trace("End of transaction: " + Command);
multiplexer.OnTransactionLog($"issuing {this.Command}"); multiplexer.OnTransactionLog($"issuing {Command}");
yield return this; // acts as either an EXEC or an UNWATCH, depending on "aborted" yield return this; // acts as either an EXEC or an UNWATCH, depending on "aborted"
} }
...@@ -424,6 +427,7 @@ public override bool SetResult(PhysicalConnection connection, Message message, R ...@@ -424,6 +427,7 @@ public override bool SetResult(PhysicalConnection connection, Message message, R
protected override bool SetResultCore(PhysicalConnection connection, Message message, RawResult result) protected override bool SetResultCore(PhysicalConnection connection, Message message, RawResult result)
{ {
connection?.BridgeCouldBeNull?.Multiplexer?.OnTransactionLog($"got {result} for {message.CommandAndKey}");
if (message is TransactionMessage tran) if (message is TransactionMessage tran)
{ {
var bridge = connection.BridgeCouldBeNull; var bridge = connection.BridgeCouldBeNull;
...@@ -457,6 +461,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes ...@@ -457,6 +461,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
var arr = result.GetItems(); var arr = result.GetItems();
if (result.IsNull) if (result.IsNull)
{ {
connection?.BridgeCouldBeNull?.Multiplexer?.OnTransactionLog($"aborting wrapped messages (failed watch)");
connection.Trace("Server aborted due to failed WATCH"); connection.Trace("Server aborted due to failed WATCH");
foreach (var op in wrapped) foreach (var op in wrapped)
{ {
...@@ -469,8 +474,10 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes ...@@ -469,8 +474,10 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
else if (wrapped.Length == arr.Length) else if (wrapped.Length == arr.Length)
{ {
connection.Trace("Server committed; processing nested replies"); connection.Trace("Server committed; processing nested replies");
connection?.BridgeCouldBeNull?.Multiplexer?.OnTransactionLog($"processing {arr.Length} wrapped messages");
for (int i = 0; i < arr.Length; i++) for (int i = 0; i < arr.Length; i++)
{ {
connection?.BridgeCouldBeNull?.Multiplexer?.OnTransactionLog($"> got {arr[i]} for {wrapped[i].Wrapped.CommandAndKey}");
if (wrapped[i].Wrapped.ComputeResult(connection, arr[i])) if (wrapped[i].Wrapped.ComputeResult(connection, arr[i]))
{ {
bridge.CompleteSyncOrAsync(wrapped[i].Wrapped); bridge.CompleteSyncOrAsync(wrapped[i].Wrapped);
......
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