使用 PGPOOL 集群时,Npgsql 无法正常工作

Npgsql does not work properly, when using PGPOOL cluster

我的问题详情如下,

工作环境

查询数据库时经常出现以下错误(异常情况可能因时间和发生地点而异)。

ERROR System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at Npgsql.NpgsqlBuffer.Ensure(Int32 count)
at Npgsql.NpgsqlConnector.DoReadSingleMessage(DataRowLoadingMode dataRowLoadingMode, Boolean returnNullForAsyncMessage, Boolean isPrependedMessage)
at Npgsql.NpgsqlConnector.ReadSingleMessage(DataRowLoadingMode dataRowLoadingMode, Boolean returnNullForAsyncMessage)
at Npgsql.NpgsqlCommand.Execute(CommandBehavior behavior)
at Npgsql.NpgsqlCommand.ExecuteDbDataReaderInternal(CommandBehavior behavior)
at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func3 operation, TInterceptionContext interceptionContext, Action3 executing, Action3 executed)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)

或:

ERROR System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at Npgsql.NpgsqlBuffer.Ensure(Int32 count)
at Npgsql.NpgsqlConnector.DoReadSingleMessage(DataRowLoadingMode dataRowLoadingMode, Boolean returnNullForAsyncMessage, Boolean isPrependedMessage)
at Npgsql.NpgsqlConnector.ReadSingleMessage(DataRowLoadingMode dataRowLoadingMode, Boolean returnNullForAsyncMessage)
at Npgsql.NpgsqlConnector.ReadExpectingT
at Npgsql.NpgsqlConnector.ExecuteInternalCommand(FrontendMessage message, Boolean withTimeout)
at Npgsql.NpgsqlTransaction.Commit()
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action2 operation, TInterceptionContext interceptionContext, Action3 executing, Action3 executed)

没有 pgpool 的相同查询 运行,不会出现上述异常。

你能建议我解决这个问题吗?

提前致谢。

这似乎是 https://github.com/npgsql/npgsql/issues/1060 的重复,后者已得到修复。尝试使用非常新的 3.1.0 看看它是否能解决您的问题(注意,它可能有点原始),或者等到 3.0.8 出来 - 它也会包含修复程序。