Skip to content

rare NullReferenceException from ServerEndPoint.get_LastException() #1342

@AdamOutcalt

Description

@AdamOutcalt

We've been using 2.0.601 for months, and only seen one instance of this - seems pretty rare.

Exception=System.NullReferenceException: Object reference not set to an instance of an object.
   at StackExchange.Redis.ServerEndPoint.get_LastException()
   at StackExchange.Redis.ExceptionFactory.PopulateInnerExceptions(ReadOnlySpan`1 serverSnapshot)
   at StackExchange.Redis.ExceptionFactory.NoConnectionAvailable(Boolean includeDetail, Boolean includePerformanceCounters, RedisCommand command, Message message, ServerEndPoint server, ReadOnlySpan`1 serverSnapshot)
   at StackExchange.Redis.ConnectionMultiplexer.GetException(WriteResult result, Message message, ServerEndPoint server)
   at StackExchange.Redis.ConnectionMultiplexer.ExecuteAsyncImpl[T](Message message, ResultProcessor`1 processor, Object state, ServerEndPoint server)
   at StackExchange.Redis.RedisBase.ExecuteAsync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server)
   at StackExchange.Redis.RedisDatabase.HashGetAllAsync(RedisKey key, CommandFlags flags)
   at StackExchange.Redis.KeyspaceIsolation.WrapperBase`1.HashGetAllAsync(RedisKey key, CommandFlags flags)

I'm sorry that I'm not more familiar with this project to contribute more. My best guess is on this line:

if (tmp2?.LastException != null && tmp2.LastException.Data.Contains("Redis-FailureType") && !tmp2.LastException.Data["Redis-FailureType"].ToString().Equals(nameof(ConnectionFailureType.UnableToConnect)))

The first clause checks that LastException is not null; but maybe it can be set to null on PhysicalBridge.OnFullyEstablished, and then the later checks may be working with null? I'm not sure when that event may fire relative to execution.

Otherwise, maybe there's a way for Data to not be populated?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions