Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple Simultaneous SQL Connection Timeouts (Threading)
    primarykey
    data
    text
    <p>I am working with a Console app that is using Parallel.foreach for threading purposes. It was developed using .net 4.5 vs 2012 that is retrieving and inserting data into sql server (2008 r2) that is on site. So there should be no network issues because the sql server is local. My application is currently the only one using the database I am getting a ton of timeouts from several threads at the same time. What makes this more confusing is I can call this application over and over but that one time I get the timeout. Maybe this is simple as increasing the timeout but I wonder if there is something else going on</p> <p>This is the stored procedure I am calling </p> <pre><code>Select table.Id from Table WITH (NOLOCK) inner join table2 c WITH (NOLOCK) on c.Id = table.TableId inner join Table3_xref x WITH (NOLOCK) on x.TableID = c.id inner join Table4 p WITH (NOLOCK) on p.id = x.id where value = @Parm1 and p.Value1 = @Parm2 and c.Value2 = @Parm3 and Table.Void = 0 </code></pre> <p>This is the exception</p> <p>System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action<code>1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action</code>1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp; task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task&amp; task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()</p> <p>This is what my code looks like</p> <pre><code> try { using (DbConnection con = Database.CreateConnection()) { IDbCommand cmd = new SqlCommand(sSQL, (SqlConnection)con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); IDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { result = true; } } } </code></pre> <p>After a while the program is able to recover and continue its task. I would consider this a duplicate to <a href="https://stackoverflow.com/questions/5884876/multiple-simultaneous-sql-connection-timeouts-in-multithreaded-windows-service">this</a> but I am not using database mirroring and this is not happening on connection.open</p> <p>I can increase the time out from the default but I am not real sure this should be a issue.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload