@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?
ErrorLogging
plugin?Cofoundry.Plugins.ErrorLogging.Data.ErrorLoggingDbContext
throwing 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!
IAuthConfiguration
and 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
LoginPath
to 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
I have a class that will return a list of Page Directories for a select list in the DataModel
public class PageDirectoryOptionSource : IListOptionSource
{
private CofoundryDbContext dbContext;
public PageDirectoryOptionSource(CofoundryDbContext dbContext)
{
this.dbContext = dbContext;
}
public ICollection<ListOption> Create()
{
return (from p in dbContext.PageDirectories select new ListOption(p.Name, p.PageDirectoryId)).ToArray();
}
}
It will not inject the CofoundryDbContext. What alternative do I have build a list for the user based on information stored in the Cofoundry database? or What would be the best way to build a table of contents based on Page Directory?
Having this issue with hosting on an Azure App Service - I developed a Custom Entity similar to the Blog Post examples. After I publish a new custom entity, and not logged into Cofoundry - I see this error in the log when browsing to the root of the site or any of the post NOT logged in. I can login into the admin but when the site begins to behave like this, I can no longer go into the Custom Entities settings. The same error below occurs. I have seen some behavior with deleting the cookies specifically the ARRAFINITY cookies. This does not occur every when running locally.
Main
MESSAGE:
Entity of type 'Cofoundry.Domain.CustomEntityRoute' and identifier '2' could not be found.