Question

When executing SQL Statements, I sometimes get errors

Client:

"An exception occurred while executing a Transact-SQL statement or batch. A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 -The semaphore timeout period has expired)"

SQL Server:

"2014-02-09 11:02:31.81 Server A fatal error occurred while reading the input stream from the network. The session will be terminated (input error: 64, output error: 0)."

I have managed to find one piece of SQL that consistently fails, from my generated database scripts, which I run when deploying a new version (though I see the error intermittently elsewhere too):

/*************************************************/
/* [dbo].gspFolderDataCache_SEARCH */
/*************************************************/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id =     OBJECT_ID(N'[dbo].gspFolderDataCache_SEARCH') AND type in (N'P', N'PC')) DROP PROCEDURE [dbo].gspFolderDataCache_SEARCH
GO

CREATE PROCEDURE [dbo].gspFolderDataCache_SEARCH (@FolderId AS [uniqueidentifier],   @PerformanceFolderId AS [uniqueidentifier], @ShowFolderId AS [uniqueidentifier], @SpaceFolderId AS [uniqueidentifier], @VenueFolderId AS [uniqueidentifier])
AS

SELECT
FolderId, PerformanceFolderId, ShowFolderId, SpaceFolderId, VenueFolderId
FROM
[dbo].[FolderDataCache]
WHERE
([FolderId] = @FolderId OR @FolderId IS NULL)
 AND ([PerformanceFolderId] = @PerformanceFolderId OR @PerformanceFolderId IS NULL)
 AND ([ShowFolderId] = @ShowFolderId OR @ShowFolderId IS NULL)
 AND ([SpaceFolderId] = @SpaceFolderId OR @SpaceFolderId IS NULL)
 AND ([VenueFolderId] = @VenueFolderId OR @VenueFolderId IS NULL)

GO

whilst this, almost identical script, works every time:

/*************************************************/
/* [dbo].gspDiscounts_SEARCH */
/*************************************************/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].gspDiscounts_SEARCH') AND type in (N'P', N'PC')) DROP PROCEDURE [dbo].gspDiscounts_SEARCH
GO

CREATE PROCEDURE [dbo].gspDiscounts_SEARCH (@DiscountId AS [uniqueidentifier], @DiscountName AS [nvarchar](50), @DiscountDescription AS [nvarchar](max))
AS

SELECT
    DiscountId, DiscountName, DiscountDescription
FROM
    [dbo].[Discounts]
WHERE
    ([DiscountId] = @DiscountId OR @DiscountId IS NULL)
     AND ([DiscountName] LIKE @DiscountName OR @DiscountName IS NULL)
     AND ([DiscountDescription] LIKE @DiscountDescription OR @DiscountDescription IS NULL)

GO

In this particular example, where the SQL is being executed by my database maintenance tool, I am using the SQL Server management objects to run the scripts, but the same error occurs in the main application which uses the Enterprise Library Data Access Block, so I don't think it's in the C# code.

Both the SQL Server (SQL Server v2008 R2) and the client are on Amazon EC2 servers, inside the same VPC. When the webserver was outside the VPC and running Windows Server 2008, this problem didn't occur. Both servers are now on Windows Server 2012

Because the statement that fails is so similar to the one that works, and because it shows as a network error on both the client and the server, I thought it might be something in between... I've turned the Windows Firewall off on both servers. That hasn't helped.

What on earth can be going on?

Était-ce utile?

La solution 2

Looks like a combination of 2 things:

  1. The default MTU of 1500 is too high for Amazon Server
  2. Blocking ICMP (default for an AWS security group) stops the negotiation of a suitable MTU.

Setting a lower MTU and enabling IMCP seems to have fixed it, so far, anyway.

Autres conseils

"Have you tried turning it off an on again?"

Not my first recourse with production servers, but now at 25 minutes past midnight I can confirm that (with the application of all pending windows updates) seems to have cleared the problem.

Tch.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top