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

track the last command

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