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)
muxer.ConnectionFailed += OnConnectionFailed;
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.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.Closing += complete => Writer.WriteLine(complete ? "Closed" : "Closing...");
return muxer;
......
......@@ -162,6 +162,9 @@ protected override void WriteImpl(PhysicalConnection physical)
Wrapped.SetRequestSent();
}
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>
......@@ -174,6 +177,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
{
if (message is QueuedMessage q)
{
connection?.BridgeCouldBeNull?.Multiplexer?.OnTransactionLog($"observed QUEUED for " + q.Wrapped?.CommandAndKey);
q.WasQueued = true;
}
return true;
......@@ -318,7 +322,6 @@ public IEnumerable<Message> GetMessages(PhysicalConnection connection)
}
multiplexer.OnTransactionLog($"issued {InnerOperations.Length} operations");
if (explicitCheckForQueued && lastBox != null)
{
multiplexer.OnTransactionLog($"checking conditions in the *late* path");
......@@ -373,7 +376,7 @@ public IEnumerable<Message> GetMessages(PhysicalConnection connection)
}
}
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"
}
......@@ -424,6 +427,7 @@ public override bool SetResult(PhysicalConnection connection, Message message, R
protected override bool SetResultCore(PhysicalConnection connection, Message message, RawResult result)
{
connection?.BridgeCouldBeNull?.Multiplexer?.OnTransactionLog($"got {result} for {message.CommandAndKey}");
if (message is TransactionMessage tran)
{
var bridge = connection.BridgeCouldBeNull;
......@@ -457,6 +461,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
var arr = result.GetItems();
if (result.IsNull)
{
connection?.BridgeCouldBeNull?.Multiplexer?.OnTransactionLog($"aborting wrapped messages (failed watch)");
connection.Trace("Server aborted due to failed WATCH");
foreach (var op in wrapped)
{
......@@ -469,8 +474,10 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
else if (wrapped.Length == arr.Length)
{
connection.Trace("Server committed; processing nested replies");
connection?.BridgeCouldBeNull?.Multiplexer?.OnTransactionLog($"processing {arr.Length} wrapped messages");
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]))
{
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