0

I have this happening from time to time on my Production application.

My scenario is a simple one, as follows:

using (var ctx = new MyDbContext())
{
  ctx.SMSReplies.Add(new SMSReply
  {
    //Set properties here
  });
  ctx.SaveChanges();
}

Occasionally this fails with the following error:

System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.

---> System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details.

---> System.Data.SqlClient.SqlException: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated.

---> System.ComponentModel.Win32Exception: The wait operation timed out

I know I could increase the command timeout of my DbContext, but that's not the point; my concern runs deeper than that...

The default timeout is 30 seconds, and so my concern is...what on earth can be going on in my database that can cause a simple insert of a line into a table with less than 5000 rows to take longer than 30 seconds?!?!

Any DBA's out there that can guide me on what performance monitoring and tuning I should be doing on my database to shed light on the root cause?

Shawn de Wet
  • 5,642
  • 6
  • 57
  • 88
  • Maybe some other process holds a table lock on the `SMSReplies` table (e.g. because it executes a complex query) while you are trying to insert, resulting in a deadlock. See [A very quick guide to deadlock diagnosis in SQL Server](https://dzone.com/articles/very-quick-guide-deadlock) – Georg Patscheider Oct 12 '18 at 09:26
  • Thanks @GeorgPatscheider I thought of that...but a deadlock will return a different exception (something about you have been chosen as the deadlock victim. Rerun your transaction). – Shawn de Wet Oct 12 '18 at 14:41

1 Answers1

-1

I'm currently debugging the same issue -- did you come across any divine solutions?