Commit 5afb8a5d authored by Marc Gravell's avatar Marc Gravell

track the last command

parent efa74341
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
{ {
internal enum RedisCommand internal enum RedisCommand
{ {
NONE, // must be first for "zero reasons"
APPEND, APPEND,
ASKING, ASKING,
AUTH, AUTH,
......
...@@ -86,6 +86,8 @@ public long SubscriptionCount ...@@ -86,6 +86,8 @@ public long SubscriptionCount
internal long OperationCount => Interlocked.Read(ref operationCount); internal long OperationCount => Interlocked.Read(ref operationCount);
public RedisCommand LastCommand { get; private set; }
public void Dispose() public void Dispose()
{ {
isDisposed = true; isDisposed = true;
...@@ -103,10 +105,12 @@ public void Dispose() ...@@ -103,10 +105,12 @@ public void Dispose()
// in a finalizer, but we need to kill that socket, // in a finalizer, but we need to kill that socket,
// and this is the first place that isn't going to // and this is the first place that isn't going to
// be rooted by the socket async bits // be rooted by the socket async bits
try { try
{
var tmp = physical; var tmp = physical;
tmp?.Shutdown(); tmp?.Shutdown();
} catch { } }
catch { }
} }
public void ReportNextFailure() public void ReportNextFailure()
{ {
...@@ -342,7 +346,7 @@ private void AbandonPendingBacklog(Exception ex) ...@@ -342,7 +346,7 @@ private void AbandonPendingBacklog(Exception ex)
do do
{ {
next = DequeueNextPendingBacklog(); next = DequeueNextPendingBacklog();
if(next != null) if (next != null)
{ {
Multiplexer?.OnMessageFaulted(next, ex); Multiplexer?.OnMessageFaulted(next, ex);
next.SetException(ex); next.SetException(ex);
...@@ -671,12 +675,13 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne ...@@ -671,12 +675,13 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne
try try
{ {
var cmd = message.Command; var cmd = message.Command;
LastCommand = cmd;
bool isMasterOnly = message.IsMasterOnly(); bool isMasterOnly = message.IsMasterOnly();
if (isMasterOnly && ServerEndPoint.IsSlave && (ServerEndPoint.SlaveReadOnly || !ServerEndPoint.AllowSlaveWrites)) if (isMasterOnly && ServerEndPoint.IsSlave && (ServerEndPoint.SlaveReadOnly || !ServerEndPoint.AllowSlaveWrites))
{ {
throw ExceptionFactory.MasterOnly(Multiplexer.IncludeDetailInExceptions, message.Command, message, ServerEndPoint); throw ExceptionFactory.MasterOnly(Multiplexer.IncludeDetailInExceptions, message.Command, message, ServerEndPoint);
} }
if (message.Command == RedisCommand.QUIT) connection.RecordQuit(); if (cmd == RedisCommand.QUIT) connection.RecordQuit();
SelectDatabaseInsideWriteLock(connection, message); SelectDatabaseInsideWriteLock(connection, message);
if (!connection.TransactionActive) if (!connection.TransactionActive)
......
...@@ -325,7 +325,8 @@ public Task FlushAsync() ...@@ -325,7 +325,8 @@ public Task FlushAsync()
{ {
if (bridge != null) if (bridge != null)
{ {
exMessage.Append(" on ").Append(Format.ToString(bridge.ServerEndPoint?.EndPoint)).Append("/").Append(connectionType); exMessage.Append(" on ").Append(Format.ToString(bridge.ServerEndPoint?.EndPoint)).Append("/").Append(connectionType)
.Append(", last: ").Append(bridge.LastCommand);
data.Add(Tuple.Create("FailureType", failureType.ToString())); data.Add(Tuple.Create("FailureType", failureType.ToString()));
data.Add(Tuple.Create("EndPoint", Format.ToString(bridge.ServerEndPoint?.EndPoint))); data.Add(Tuple.Create("EndPoint", Format.ToString(bridge.ServerEndPoint?.EndPoint)));
......
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