NickCraver / StackExchange.Exceptional

Error handler used for the Stack Exchange network
https://nickcraver.com/StackExchange.Exceptional/
Apache License 2.0
860 stars 170 forks source link

Could not find error store type: SQL - ASPNET Core 2 #110

Closed nickalbrecht closed 6 years ago

nickalbrecht commented 6 years ago

I updated an app using Exceptional to ASP.NET Core 2 this week, and noticed that periodically I'm getting an error when trying to access the error log. It works fine for a while, then it just keeps coming up with the message

Could not find error store typ: SQL

Using Exceptional 2.0.0-alpha-129

If I cycle the app pool, it comes back up. My assumption is that while it's like this, it's also not recording errors into the log, and I'm not getting any emails about this or any other errors either.

at StackExchange.Exceptional.ErrorStore.Get(ErrorStoreSettings settings)
   at StackExchange.Exceptional.Settings.get_DefaultStore()
   at StackExchange.Exceptional.ExceptionalMiddleware.<HandleRequestAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MyAppNamespace.ErrorsController.<Exceptions>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextExceptionFilterAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ExceptionContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at StackExchange.Exceptional.ExceptionalMiddleware.<Invoke>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at StackExchange.Exceptional.ExceptionalMiddleware.<Invoke>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
NickCraver commented 6 years ago

I'm puzzled how this would happen, since the SQL error store is in the DLL that's running that code...so there's no assembly loading issue in play.

What does you config look like here?

nickalbrecht commented 6 years ago

I never saw this error on ASPNET Core 1.x, it seems to be new to 2.0? I'm still getting it so it's not that sporadic, just unsure how to reproduce it on demand.

appsettings.json

"Exceptional": {
    "ApplicationName": "MyApp Dev",
    "UseExceptionalPageOnThrow": false,
    "LogFilters": {
        "Form": {
            "password": "*** masked for security purposes ***",
            "CardNumber": "*** masked for security purposes ***",
            "CVD": "*** masked for security purposes ***",
            "ExpiryYear": "*** masked for security purposes ***",
            "ExpiryMonth": "*** masked for security purposes ***"
        },
        "Cookies": {
            ".AspNetCore.Session": "*** masked for security purposes ***",
            ".AspNetCore.Antiforgery": "*** masked for security purposes ***",  //This doesn't work, because the cookie name suffix is random
        }
    },
    "IgnoreErrors": {
        "Types": [ "MyApp.DomainException" ],
        "Regexes": [ "The operation has timed out", "The transaction has aborted." ]
    },
    "Email": {
        "fromAddress": "me@example.com",
        "SMTPHost": "127.0.0.1"
    }
}

appsettings.production.json

"Exceptional": {
    "ApplicationName": "MyApp",
    "ErrorStore": {
        "Type": "SQL",
        "ConnectionString": "**CONNECTION_STRING**"
    },
    "Email": {
        "FromDisplayName": "MyApp Error",
        "ToAddress": "me@example.com, someone@example.com"
    }
}
StefanKert commented 6 years ago

@nickalbrecht If you´re running the latest version of Exceptional you need to change your settings. ErrorStore got renamed to Store

https://github.com/NickCraver/StackExchange.Exceptional/blob/5b252b6a4ff44e9cdb502d717f2a0ed2e1f19237/samples/Samples.AspNetCore/appsettings.json#L77-L81

nickalbrecht commented 6 years ago

I'm running the latest from Nuget. It does work in my staging environment, just not my production one. I tried changing my appsettings to "Store" instead of "ErrorStore", and it no longer works in Staging, so the bits for that change don't appear to be on Nuget yet. I just did a new publish this afternoon and it's back to working on Production, so I'm waiting to see if it starts failing again or not. That's been the pattern so far.

NickCraver commented 6 years ago

I'm at a loss here since they're in the same assembly, but this has all been tweaked a bit in the next alpha. Alpha 2 should land on NuGet in a few minutes - can you please give it a try? Note the updated JSON config to match the OO structure directly.

nickalbrecht commented 6 years ago

Absolutely. I'll give it a shot. I agree, there's not much point in looking into the issue until I can verify if it's still happening in the current bits. I just haven't have the chance to look into it yet. Been tackling other fires. I'll try it out tomorrow.

NickCraver commented 6 years ago

Alrighty I think I figured out what's happening here - finally able to reproduce it in a test. Are you able to check out 2.0.0-alpha2-00174 or higher on MyGet and see if you're good to go? If so I'll promote that up to NuGet for everyone.

Thanks again for all the testing here, it's greatly appreciated!

nickalbrecht commented 6 years ago

No problem. It seems to be ok, now but I'd wait and see if it pops up again just in case. Wrote you a novel in the other issue regarding reloading source configurations and IOptions<> vs IOptionsSnapshot<>.

NickCraver commented 6 years ago

I really believe we're good here - so closing this out. If you hit it again we'll re-open :)