Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用正确的凭据获取SQL Server超时错误,使用(故意)不正确的凭据立即拒绝_C#_.net_Sql Server_Linq To Sql_Timeout - Fatal编程技术网

C# 使用正确的凭据获取SQL Server超时错误,使用(故意)不正确的凭据立即拒绝

C# 使用正确的凭据获取SQL Server超时错误,使用(故意)不正确的凭据立即拒绝,c#,.net,sql-server,linq-to-sql,timeout,C#,.net,Sql Server,Linq To Sql,Timeout,这是一个令人困惑的问题。我的ASP.NET 3.5应用程序运行正常,但突然出现超时错误 System.Data.SqlClient.SqlException:超时已过期。操作完成前的超时时间或服务器没有响应 …但仅适用于连接字符串中具有正确用户名/密码的请求。如果我们故意弄乱了配置中的连接字符串,SQL Server将正确地拒绝该请求,但会立即拒绝,而不是在等待15秒(配置的超时)之后,这清楚地表明它与服务器通信没有问题 我们跳出了SQL Server框(SQL Server 2005,完全修补

这是一个令人困惑的问题。我的ASP.NET 3.5应用程序运行正常,但突然出现超时错误

System.Data.SqlClient.SqlException:超时已过期。操作完成前的超时时间或服务器没有响应

…但仅适用于连接字符串中具有正确用户名/密码的请求。如果我们故意弄乱了配置中的连接字符串,SQL Server将正确地拒绝该请求,但会立即拒绝,而不是在等待15秒(配置的超时)之后,这清楚地表明它与服务器通信没有问题

我们跳出了SQL Server框(SQL Server 2005,完全修补)和IIS框,触摸了web.config以强制重新启动应用程序,等等,但没有成功。所有请求将挂起15秒,然后报告该错误。在任何时候,我们都能够直接访问数据库服务器(ManagementStudio、监视工具),并且我能够在VisualStudio中配置我的本地站点副本,以无事故地访问同一数据库服务器。这个问题突然出现,并且持续了一天的大部分时间(错误在早上6:17开始被记录),在下午4:30左右突然解决了

这似乎表现得好像在这台web服务器和这台数据库服务器之间存在网络路由问题,但仅使用一组特定的SQL凭据。我知道这没有任何意义,但没有任何其他我们可以想象的场景。我是一个非常有经验的开发人员,无论是我还是我们非常有经验的DBA还是系统管理员,都无法在事件日志、监控异常情况等中找到任何可以合理解释这一奇怪且自我解决的症状集的东西

这发生在我们客户的测试环境中,这并不理想,但因为我们不了解到底发生了什么,我们担心这可能会在生产中突然出现,我们将集体碰壁,所以任何想法或疯狂的理论都是非常受欢迎的

正在爆炸的LINQ到SQL生成的代码行是ExecuteMethodCall:

[Function(Name="dbo.spSetModelingNodeState")]
public int spSetModelingNodeState([Parameter(Name="NodeIdentifier", DbType="VarChar(60)")] string nodeIdentifier, [Parameter(Name="NodeStatus", DbType="Int")] System.Nullable<int> nodeStatus, [Parameter(Name="PoolWeighting", DbType="Float")] System.Nullable<double> poolWeighting)
{
    IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), nodeIdentifier, nodeStatus, poolWeighting);
    return ((int)(result.ReturnValue));
}
编辑:花了几天的时间进行跟踪,但我在下面添加了日志/探查器信息、每个评论员请求以及相关存储过程的主体

SQL Server日志只显示登录和注销,没有问题迹象。探查器跟踪也没有冒烟的枪,但下面的似乎显示了花费18秒的语句。遵循spid 82。它在4:37:50开始,执行一些操作,然后spid 83在4:38:07记录登录。Spid 82下一步记录其完成情况,使用相同的4:38:07开始时间,但由于这些时间是按顺序记录的,因此它必须实际发生在4:38:07(以前的跟踪语句)和4:40:10(下面的语句)之间

Spid开始时间事件查询 82 4:37:50 PM登录--网络协议:LPC set quoted_标识符在set arithabort上偏移数值_RONDABORT偏移ansi_警告在set ansi_上填充在set ANSIU上空白在set concat上空白在set cursor上空白在set cursor上空白在set cursor上空白在set close上空白在set commit上偏移在set implicit_事务关闭 82下午4:37:50 SP:StmtStarting EXEC@RETURN_VALUE=[dbo].[SPSETModelingNodeEstate]@NodeIdentifier=@p0、@NodeStatus=@p1、@PoolWeighting=@p2 82下午4:37:50 SP:正在启动EXEC@RETURN_VALUE=[dbo].[SPSETModelingNodeEstate]@NodeIdentifier=@p0、@NodeStatus=@p1、@PoolWeighting=@p2 82下午4:37:50 SP:StmtStarting更新建模NodeStatus集NodeStatus=@NodeStatus,PoolWeighting=ISNULL(@PoolWeighting,PoolWeighting),其中NodeIdentifier=@NodeIdentifier 83 4:38:07 PM登录--网络协议:LPC set quoted_标识符在set arithabort上偏移数值_roundabort off set ansi_警告在set ansi_上填充在set ANSIU上空在set concat上空在set cursor上空在set cursor上空在set close上空在set close上提交偏移在set implicit_事务关闭 82下午4:37:50 SP:Completed EXEC@RETURN_VALUE=[dbo].[SPSetModelingNodeEstate]@NodeIdentifier=@p0、@NodeStatus=@p1、@PoolWeighting=@p2 80下午4:40:10 SP:StmtStarting选择“服务器[@Name=”+quotename(CAST(serverproperty(N'Servername')作为系统名),''''''''+']+'''+/数据库[@Name='+quotename(db_Name(),''''')+'//Table[@Name='+quotename(tbl.Name),'''+'和@Schema='+quotename(Schema_名称(tbl.Schema++.Schema++)id),'''''''')]]](tbl.schema_id)为[schema],CAST(tbl.is_ms_shipped时为1,则当(从sys.extended_properties中选择major_id,其中major_id=tbl.object_id和minor_id=0,class=1,name=N'microsoft_database_tools_support'不为空,则1或0以位结束)作为[IsSystemObject],tbl.create_date作为[CreateDate],stbl.name作为[Owner]从sys.tables作为tbl内部连接sys.database_主体作为stbl ON stbl.principal_id=ISNULL(tbl.principal_id,(OBJECTPROPERTY(tbl.object_id,'OwnerId')),其中(强制转换(tbl.is_ms_shipped=1时的情况)(从sys.extended_properties中选择major_id,其中major_id=tbl.object_id和minor_id=0,class=1,name=N'microsoft_database_tools_support'不为空,则1或0以位结束)=@_msparam_0)按[Schema]ASC、[Name]ASC排序 80下午4:40:10 SQL:BatchStarting使用[master] 62下午4:20:10注销无效 55下午4:20:02注销无效 74下午4:13:37注销无效 59下午4:20:10注销NUL
using (MyDataContext myDataContext = new MyDataContext(_connectionString))
{
    myDataContext.spSetModelingNodeState(
        Adapter.Identifier, // string
        (int)newHealthValue, // enum, cast to int
        PoolWeighting); // float
}
Spid Starttime Event Query 82 4:37:50 PM Login -- network protocol: LPC set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off 82 4:37:50 PM SP:StmtStarting EXEC @RETURN_VALUE = [dbo].[spSetModelingNodeState] @NodeIdentifier = @p0, @NodeStatus = @p1, @PoolWeighting = @p2 82 4:37:50 PM SP:Starting EXEC @RETURN_VALUE = [dbo].[spSetModelingNodeState] @NodeIdentifier = @p0, @NodeStatus = @p1, @PoolWeighting = @p2 82 4:37:50 PM SP:StmtStarting UPDATE ModelingNodeState SET NodeStatus = @NodeStatus, PoolWeighting = ISNULL(@PoolWeighting, PoolWeighting) WHERE NodeIdentifier = @NodeIdentifier 83 4:38:07 PM Login -- network protocol: LPC set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off 82 4:37:50 PM SP:Completed EXEC @RETURN_VALUE = [dbo].[spSetModelingNodeState] @NodeIdentifier = @p0, @NodeStatus = @p1, @PoolWeighting = @p2 80 4:40:10 PM SP:StmtStarting SELECT 'Server[@Name=' + quotename(CAST(serverproperty(N'Servername') AS sysname),'''') + ']' + '/Database[@Name=' + quotename(db_name(),'''') + ']' + '/Table[@Name=' + quotename(tbl.name,'''') + ' and @Schema=' + quotename(SCHEMA_NAME(tbl.schema_id),'''') + ']' AS [Urn], tbl.name AS [Name], SCHEMA_NAME(tbl.schema_id) AS [Schema], CAST( case when tbl.is_ms_shipped = 1 then 1 when ( select major_id from sys.extended_properties where major_id = tbl.object_id and minor_id = 0 and class = 1 and name = N'microsoft_database_tools_support') is not null then 1 else 0 end AS bit) AS [IsSystemObject], tbl.create_date AS [CreateDate], stbl.name AS [Owner] FROM sys.tables AS tbl INNER JOIN sys.database_principals AS stbl ON stbl.principal_id = ISNULL(tbl.principal_id, (OBJECTPROPERTY(tbl.object_id, 'OwnerId'))) WHERE (CAST( case when tbl.is_ms_shipped = 1 then 1 when ( select major_id from sys.extended_properties where major_id = tbl.object_id and minor_id = 0 and class = 1 and name = N'microsoft_database_tools_support') is not null then 1 else 0 end AS bit)=@_msparam_0) ORDER BY [Schema] ASC,[Name] ASC 80 4:40:10 PM SQL:BatchStarting use [master] 62 4:20:10 PM Logout NULL 55 4:20:02 PM Logout NULL 74 4:13:37 PM Logout NULL 59 4:20:10 PM Logout NULL 55 4:40:29 PM Login -- network protocol: TCP/IP set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions 55 4:40:29 PM SQL:BatchStarting set transaction isolation level read committed set implicit_transactions off 82 4:37:50 PM Logout NULL
/****** Object:  StoredProcedure [dbo].[spSetModelingNodeState]    Script Date: 10/29/2010 14:37:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spSetModelingNodeState]
(
@NodeIdentifier varchar(60),
@NodeStatus int,
@PoolWeighting float = NULL
)
AS
/*try to update existing row to new state*/
UPDATE
    ModelingNodeState
SET
    NodeStatus = @NodeStatus,
    PoolWeighting = ISNULL(@PoolWeighting, PoolWeighting)
WHERE
    NodeIdentifier = @NodeIdentifier

IF @@ROWCOUNT = 0
    /*not found, so insert new one*/
    INSERT
        ModelingNodeState(
            NodeIdentifier,
            PoolWeighting,
            NodeStatus,
            LastModelingResult)
    VALUES(
        @NodeIdentifier,
        ISNULL(@PoolWeighting, 1),
        0,
        NULL)

DECLARE @timestamp datetime
SET @timestamp = CURRENT_TIMESTAMP

/*fill endtime of previous node state*/
UPDATE 
    ModelingNodeStateLog
SET
    EndTime = @timestamp
WHERE
    EndTime IS NULL AND
    NodeIdentifier = @NodeIdentifier AND
    NodeStatus <> @NodeStatus

/*start a new entry in the log (yes, I saw I should remove the IF check and always insert, but that's how it currently is in the db)*/
IF @@ROWCOUNT <> 0
    INSERT
        ModelingNodeStateLog
        (
        NodeIdentifier,
        NodeStatus,
        StartTime
        )
    VALUES
        (
        @NodeIdentifier,
        @NodeStatus,
        @timestamp
        )

RETURN