Currently my windows service is processing approximately 1500 transacations a day. About once a week I get a random timeout exception on an Insert done using LINQ.
The exception is:
Exception (SqlException) System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
The Linq query is:
dc.TransactionLoggings.InsertOnSubmit(new TransactionLogging()
{
DateAdded = DateTime.UtcNow,
InputMessage = message,
DocId = documentID.ToString(),
TransactionStatus = transactionStatus
});
dc.SubmitChanges();
Any ideas/suggestions on what to do to diagnose this??
Many thanks for your help, Fiona
UPDATE
The table structure is:
CREATE TABLE [dbo].[TransactionLogging](
[ID] [bigint] IDENTITY(1,1) NOT NULL,
[InputMessage] [nvarchar](max) NULL,
[CCHMessage] [nvarchar](max) NULL,
[DocId] [char](20) NOT NULL,
[TransactionStatus] [char](5) NOT NULL,
[DateAdded] [datetime] NULL,
[LastUpdate] [datetime] NULL,
[SentDate] [datetime] NULL,
CONSTRAINT [PK_TransactionLogging] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY
Furthermore, the 2 most recent transaction timeouts occured for the first transaction of the day. This is no conincidence I'm sure!
Also just wondering if anybody has any thoughts on the following update to my code:
Any comments?!!!
using (MiddlewareDBDataContext dc = new MiddlewareDBDataContext(ConfigurationWrapper.ActivityLoggingDatabase_ConnectionString))
{
dc.TransactionLoggings.InsertOnSubmit(new TransactionLogging()
{
DateAdded = DateTime.UtcNow,
InputMessage = message,
DocId = documentID.ToString(),
TransactionStatus = transactionStatus
});
try
{
dc.SubmitChanges();
}
catch (SqlException ex)
{
//Wait for 30 seconds then retry..
System.Threading.Thread.Sleep(30000);
dc.SubmitChanges();
}
}