Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NRE on ConnectionMultiplexer.WaitAllIgnoreErrors #2754

Open
czd890 opened this issue Jul 3, 2024 · 3 comments
Open

NRE on ConnectionMultiplexer.WaitAllIgnoreErrors #2754

czd890 opened this issue Jul 3, 2024 · 3 comments

Comments

@czd890
Copy link

czd890 commented Jul 3, 2024

Sometimes this error is caught on the server (out of hundreds of instances, 1-2 times every 2-3 days).
I looked through the sourcecode and this NRE exception doesn't seem to be possible. 😢

{
    "exception": {
        "Type": "System.NullReferenceException",
        "TargetSite": "Boolean WaitAllIgnoreErrors(System.Threading.Tasks.Task[])",
        "Message": "Object reference not set to an instance of an object.",
        "Data": {},
        "Source": "StackExchange.Redis",
        "HResult": -2147467261,
        "StackTrace": "   
at StackExchange.Redis.ConnectionMultiplexer.WaitAllIgnoreErrors(Task[] tasks) 
in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 463\n   
at StackExchange.Redis.ConnectionMultiplexer.Close(Boolean allowCommandsToComplete) 
in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 2301\n   
at StackExchange.Redis.ConnectionMultiplexer.Dispose() 
in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 2259\n
in mycode stacks..."
    }
}

version: 2.7.33.41805

@NickCraver
Copy link
Collaborator

Do you know if this is happening during shutdown, e.g. possibly a usage while the ConnectionMultiplexer is being disposed?

@duskembayev
Copy link

duskembayev commented Jul 21, 2024

I faced a similar issue, which reproduces occasionally when invoking ConnectionMultiplexer.CloseAsync().
Package: StackExchange.Redis 2.8.0

Executing code:

internal sealed class RedisConnection : IHostedService {
    // ...
    public async Task StopAsync(CancellationToken cancellationToken)
    {
        // ...
        await _multiplexer.CloseAsync();
        await _multiplexer.DisposeAsync();
    }
}

Exception:

System.NullReferenceException
Object reference not set to an instance of an object.
   at StackExchange.Redis.ConnectionMultiplexer.AllComplete(Task[] tasks) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 560
   at StackExchange.Redis.ConnectionMultiplexer.WaitAllIgnoreErrorsAsync(String name, Task[] tasks, Int32 timeoutMilliseconds, ILogger log, String caller, Int32 callerLineNumber) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 487
   at StackExchange.Redis.ConnectionMultiplexer.CloseAsync(Boolean allowCommandsToComplete) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 2318
   at Lib.RedisConnection.StopAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
   at Microsoft.Extensions.Hosting.Internal.Host.StopAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.DisposeAsync()
   at Enhanced.Testing.Component.Component`1.StopAsync(CancellationToken cancellationToken)
   at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in /_/src/xunit.core/Sdk/ExceptionAggregator.cs:line 90

@czd890
Copy link
Author

czd890 commented Jul 30, 2024

@NickCraver It's possible. Based on the existing logs, it's difficult to reproduce the detailed process during the failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants