.net - 套接字接收挂起在 .NET 4.5 下的 Windows 2012

标签 .net postgresql windows-server-2012 npgsql

我们有一个围绕 NHibernate 和 Npgsql 提供程序构建的 Web 应用程序,它在服务器 2008 R2 和 .NET 4 上运行良好。我们现在已经升级到 Server 2012 和 4.5 堆栈,并且遇到奇怪的挂起数据库层。

我们有一些线程会在我的测试服务器(服务器 2012 的虚拟实例)上永远卡住,并且在生产服务器上会挂起大约 7.5 或 15 分钟(大约 450 秒或 900 秒)(我只知道这是因为它通常会在日志中说明)。

当我设法在我的测试服务上重现这一点并附加调试器时,我看到一个线程将处于以下状态:

[Managed to Native Transition]   
System.dll!System.Net.Sockets.Socket.Receive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode)  
System.dll!System.Net.Sockets.NetworkStream.Read(byte[] buffer, int offset, int size)    
mscorlib.dll!System.IO.BufferedStream.ReadByte()     
Npgsql.dll!Npgsql.NpgsqlState.ProcessBackendResponses_Ver_3.MoveNext()   
Npgsql.dll!Npgsql.ForwardsOnlyDataReader.GetNextResponseObject()     
Npgsql.dll!Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()     
Npgsql.dll!Npgsql.ForwardsOnlyDataReader.NextResult()    
Npgsql.dll!Npgsql.ForwardsOnlyDataReader.ForwardsOnlyDataReader(System.Collections.Generic.IEnumerable<Npgsql.IServerResponseObject> dataEnumeration, System.Data.CommandBehavior behavior, Npgsql.NpgsqlCommand command, Npgsql.NpgsqlConnector.NotificationThreadBlock threadBlock, bool synchOnReadError)     
Npgsql.dll!Npgsql.NpgsqlCommand.GetReader(System.Data.CommandBehavior cb)    
Npgsql.dll!Npgsql.NpgsqlCommand.ExecuteBlind()   
Npgsql.dll!Npgsql.NpgsqlTransaction.Rollback()   
NHibernate.dll!NHibernate.Transaction.AdoTransaction.Rollback() 

在 postgres 端,我也看到了一个正在运行的查询,但我猜那是因为事务永远不会回滚。我们正在使用 Npgsql v2.0.12(最新的稳定版)。

这个挂起和这个极长的超时(或测试中缺少超时)的原因可能是什么?为什么它会在不同的操作系统上有所不同?

我们之前在一台服务器上使用 .NET 4.5 在服务器 2008 R2 上运行过这个,也从未见过这种行为。但我假设因为这是一个本地调用,所以它依赖于操作系统?

有没有人知道为什么会发生这种情况?

最佳答案

要检查的顺序:

  1. 服务器端的锁。

  2. 网络中断和超时。

  3. 服务器的响应能力。

  4. 长时间运行的查询。

关于.net - 套接字接收挂起在 .NET 4.5 下的 Windows 2012,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18617989/

相关文章:

c# - 是否有包含 Dapper.Net SqlBuilder 的 nuget 包?

c# - 如何在 C# 中禁用无参数构造函数

.net - VB.NET-自定义Listview/Listbox

java - PostgreSql 中的事务

sql - PostgreSQL 索引——这些是多余的吗?

postgresql - PostgreSQL 的图形查询设计器

iis - Windows Server 2012 Essentials 上的 IIS 在哪里

c# - 以编程方式查明系统是否支持待机

asp.net - microsoft azure smtp 电子邮件中继设置

c# - RabbitMQ:指定端点均不可访问