@HeyJoel, have you been running Cofoundry on ASP.NET Core 3.1 for a while now? We've been running a staging environment but at some point between 24 and 96 hours our application is depleting it's SQL connection pool it seem with this error message:
System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. at Microsoft.Data.Common.ADP.ExceptionWithStackTrace(Exception e) --- End of stack trace from previous location where exception was thrown --- at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync(Boolean errorsExpected, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync(Boolean errorsExpected, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
This also happens with an application that's not really being used, and it didn't before on .NET Core 2.2. Any clues?
Cofoundry.Plugins.ErrorLogging.Data.ErrorLoggingDbContextthrowing the error, but that might be very well caused by something else first throwing the error. The fact that it uses a different DB context is interesting though.
Thanks @technical2cents for letting us know. The group by is required for the correct stats, but EF doesn't work well with GroupBy anymore. The fixed query should be:
queryModel.NumPages = await _dbContext .PageVersions .AsNoTracking() .Where(v => v.PageTemplateId == query.PageTemplateId) .Select(v => v.Page) .Distinct() .CountAsync();
I've committed the fix, thank you!
IAuthConfigurationand the docs for DI tell you how to override stuff. If you need to inject anything into the startup pipeline the docs for that are here
LoginPathto your SSO script. Your SSO script would have to use the Cofoundry data APIs to create a Cofoundry user if it doesn't exist and log them in. The SPA Sample shows how you can use the data APIs, in particular the RegisterMemberAndLogInCommandHandler