OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.44k stars 2.4k forks source link

Error first cms load using PostgreSQL #4839

Closed Norbus closed 6 months ago

Norbus commented 4 years ago

Hello,

I'm experiencing a problem with orchard. From time to time in getting error while reading streams from db after first page load... When I try to reload page - problem disappears

Call stack:

12:38:30.459: [APP/PROC/WEB.0] 2019-11-19 11:38:30.4513|Default|0HLRCP8QN7S1P:00000001||Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware|ERROR|An unhandled exception has occurred while executing the request. Npgsql.NpgsqlException (0x80004005): Exception while reading from stream 12:38:30.459: [APP/PROC/WEB.0] ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream. 12:38:30.459: [APP/PROC/WEB.0] at Npgsql.NpgsqlReadBuffer.<>cDisplayClass34_0.<gEnsureLong|0>d.MoveNext() 12:38:30.459: [APP/PROC/WEB.0] at Npgsql.NpgsqlReadBuffer.<>cDisplayClass34_0.<gEnsureLong|0>d.MoveNext() 12:38:30.459: [APP/PROC/WEB.0] --- End of stack trace from previous location where exception was thrown --- 12:38:30.459: [APP/PROC/WEB.0] at Npgsql.NpgsqlConnector.<>cDisplayClass163_0.<gReadMessageLong|0>d.MoveNext() 12:38:30.459: [APP/PROC/WEB.0] --- End of stack trace from previous location where exception was thrown --- 12:38:30.459: [APP/PROC/WEB.0] at Npgsql.NpgsqlConnector.<>cDisplayClass163_0.<gReadMessageLong|0>d.MoveNext() 12:38:30.459: [APP/PROC/WEB.0] --- End of stack trace from previous location where exception was thrown --- 12:38:30.459: [APP/PROC/WEB.0] at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming) 12:38:30.459: [APP/PROC/WEB.0] at Npgsql.NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken) 12:38:30.459: [APP/PROC/WEB.0] at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) 12:38:30.459: [APP/PROC/WEB.0] at Dapper.SqlMapper.QueryAsync[T](IDbConnection cnn, Type effectiveType, CommandDefinition command) in C:\projects\dapper\Dapper\SqlMapper.Async.cs:line 419 12:38:30.459: [APP/PROC/WEB.0] at YesSql.Store.ProduceAsync[T](WorkerQueryKey key, Func2 work, Object[] args) 12:38:30.459: [APP/PROC/WEB.0] at YesSql.Services.DefaultQuery.Query1.ListImpl() 12:38:30.459: [APP/PROC/WEB.0] at ContentRazorHelperExtensions.QueryContentItemsAsync(IOrchardHelper orchardHelper, Func2 query) in D:\_Dev\__egmina\egmina-orchard-cms\src\OrchardCore.Modules\OrchardCore.Contents\Razor\ContentRazorHelperExtensions.cs:line 88 12:38:30.459: [APP/PROC/WEB.0] at AspNetCore.Pages_index.ExecuteAsync() in D:\_Dev\__egmina\egmina-orchard-cms\src\OrchardCore.Cms.Web\Pages\index.cshtml:line 14 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable1 statusCode) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters() 12:38:30.459: [APP/PROC/WEB.0] --- End of stack trace from previous location where exception was thrown --- 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() 12:38:30.459: [APP/PROC/WEB.0] --- End of stack trace from previous location where exception was thrown --- 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Routing.EndpointMiddleware.gAwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) 12:38:30.459: [APP/PROC/WEB.0] at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext context) 12:38:30.459: [APP/PROC/WEB.0] at OrchardCore.Media.Services.MediaFileStoreResolverMiddleware.Invoke(HttpContext context) in D:_Dev__egmina\egmina-orchard-cms\src\OrchardCore.Modules\OrchardCore.Media\Services\MediaFileStoreResolverMiddleware.cs:line 122 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) 12:38:30.459: [APP/PROC/WEB.0] at OrchardCore.Diagnostics.DiagnosticsStartupFilter.<>c__DisplayClass3_0.<b1>d.MoveNext() in D:_Dev__egmina\egmina-orchard-cms\src\OrchardCore.Modules\OrchardCore.Diagnostics\DiagnosticsStartupFilter.cs:line 47 12:38:30.459: [APP/PROC/WEB.0] --- End of stack trace from previous location where exception was thrown --- 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.gAwaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task) at Npgsql.NpgsqlReadBuffer.<>c__DisplayClass34_0.<gEnsureLong|0>d.MoveNext() 12:38:30.459: [APP/PROC/WEB.0] --- End of stack trace from previous location where exception was thrown --- 12:38:30.459: [APP/PROC/WEB.0] at Npgsql.NpgsqlConnector.<>cDisplayClass163_0.<gReadMessageLong|0>d.MoveNext() 12:38:30.459: [APP/PROC/WEB.0] --- End of stack trace from previous location where exception was thrown --- 12:38:30.459: [APP/PROC/WEB.0] at Npgsql.NpgsqlConnector.<>cDisplayClass163_0.<gReadMessageLong|0>d.MoveNext() 12:38:30.459: [APP/PROC/WEB.0] --- End of stack trace from previous location where exception was thrown --- 12:38:30.459: [APP/PROC/WEB.0] at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming) 12:38:30.459: [APP/PROC/WEB.0] at Npgsql.NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken) 12:38:30.459: [APP/PROC/WEB.0] at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) 12:38:30.459: [APP/PROC/WEB.0] at Dapper.SqlMapper.QueryAsync[T](IDbConnection cnn, Type effectiveType, CommandDefinition command) in C:\projects\dapper\Dapper\SqlMapper.Async.cs:line 419 12:38:30.459: [APP/PROC/WEB.0] at YesSql.Store.ProduceAsync[T](WorkerQueryKey key, Func2 work, Object[] args) 12:38:30.459: [APP/PROC/WEB.0] at YesSql.Services.DefaultQuery.Query1.ListImpl() 12:38:30.459: [APP/PROC/WEB.0] at ContentRazorHelperExtensions.QueryContentItemsAsync(IOrchardHelper orchardHelper, Func2 query) in D:\_Dev\__egmina\egmina-orchard-cms\src\OrchardCore.Modules\OrchardCore.Contents\Razor\ContentRazorHelperExtensions.cs:line 88 12:38:30.459: [APP/PROC/WEB.0] at AspNetCore.Pages_index.ExecuteAsync() in D:\_Dev\__egmina\egmina-orchard-cms\src\OrchardCore.Cms.Web\Pages\index.cshtml:line 14 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable1 statusCode) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters() 12:38:30.459: [APP/PROC/WEB.0] --- End of stack trace from previous location where exception was thrown --- 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() 12:38:30.459: [APP/PROC/WEB.0] --- End of stack trace from previous location where exception was thrown --- 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Routing.EndpointMiddleware.gAwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) 12:38:30.459: [APP/PROC/WEB.0] at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext context) 12:38:30.459: [APP/PROC/WEB.0] at OrchardCore.Media.Services.MediaFileStoreResolverMiddleware.Invoke(HttpContext context) in D:_Dev__egmina\egmina-orchard-cms\src\OrchardCore.Modules\OrchardCore.Media\Services\MediaFileStoreResolverMiddleware.cs:line 122 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) 12:38:30.459: [APP/PROC/WEB.0] at OrchardCore.Diagnostics.DiagnosticsStartupFilter.<>c__DisplayClass3_0.<b1>d.MoveNext() in D:_Dev__egmina\egmina-orchard-cms\src\OrchardCore.Modules\OrchardCore.Diagnostics\DiagnosticsStartupFilter.cs:line 47 12:38:30.459: [APP/PROC/WEB.0] --- End of stack trace from previous location where exception was thrown --- 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context) 12:38:30.459: [APP/PROC/WEB.0] at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

Can somebody help me with this? I don't have any idea why this happens.

jtkech commented 4 years ago

Can you show us your code in your src\OrchardCore.Cms.Web\Pages\index.cshtml.

Norbus commented 4 years ago

Sure:

@page @inject OrchardCore.IOrchardHelper Orchard @addTagHelper *, OrchardCore.Media

Aktualności
@{ var wszystkieaktualnosci = await Orchard.GetRecentContentItemsByContentTypeAsync("aktualnosci"); } @foreach (var aktualnosci in wszystkieaktualnosci) { }
sebastienros commented 4 years ago

These are due to network issues between your server and the database instance. Are you using a proxy like istio ?

System.IO.EndOfStreamException: Attempted to read past the end of the stream.

Norbus commented 4 years ago

The PostgreSQL database is behind Keepalived and HAProxy (for HA purposes). Java-based projects seem to run fine with this configuration and have no such errors.

Piedone commented 6 months ago

This doesn't seem to be still a bug, so I'll close now. Please reopen if you still experience this.