Solved

Thread was being aborted exception with Web Service/SQL Server

Posted on 2003-11-13
13
2,911 Views
Last Modified: 2007-12-19
Hi

We have a C# web service which calls SPs (via the ADO.NET SqlCommand and SqlDataAdapter objects) to read data from a SQL Sever 2000 database.  We get the following exception intermittently

Thread was being aborted.
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)    
at System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)    
at System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)    
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable, IDbCommand command, CommandBehavior behavior)     at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)  

Our connection and command timeouts are set to 30 seconds.

If anyone can help, I'd greatly appreciate an explanation or (even better) a workaround

TIA
Wile_E
0
Comment
Question by:wile_e_coyote
  • 6
  • 3
  • 2
13 Comments
 
LVL 42

Expert Comment

by:frodoman
ID: 9742198
Check your maximum concurrent connections on SQL Server.  Possibly this is intermittent because you're exceeding the max connections specified - your thread will wait for a free connection and then timeout if one isn't freed up.

0
 
LVL 5

Expert Comment

by:mondayblueboy
ID: 9746018
Do you have exception handler in the code? If yes, I suspect the error comes from a line in the try block. Post code might be helpful.

0
 
LVL 4

Author Comment

by:wile_e_coyote
ID: 9750586
Frodoman - I'm looking into your suggestion.

MondayBlueBoy - Here is (more or less) the code.   But take a look at the stack trace from above.  The error is occuring in the Fill method of the dataadapter.

DataSet ds = new DataSet();
SqlConnection cn = new SqlConnection (...);
SqlDataAdapter da = new SqlDataAdapter ();
da.SelectCommand = mySelectCmd;     //mySelectCmd is on the web service designer and is an SP call

try
{
  da.Fill (ds);
}
catch (Exception e)
...



0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 5

Expert Comment

by:mondayblueboy
ID: 9751466
Just one more q.
Is that all code in the try block?
0
 
LVL 4

Author Comment

by:wile_e_coyote
ID: 9751470
Yes
0
 
LVL 4

Author Comment

by:wile_e_coyote
ID: 9817968
Frodoman - our DBA says we are set up to allow unlimited connections
0
 
LVL 42

Expert Comment

by:frodoman
ID: 9818067
Possible user interaction during the time your fill is being executed?  Normally the "Thread being aborted" message occurs on a webform during a response.redirect / response.end type of execution (both of which always throw a ThreadAbortException).

I may be completely off base here, but if it's an intermittent problem is it possible that a user is clicking something during the fill that is causing the page to try to reload / change before the dataset is full?
0
 
LVL 4

Author Comment

by:wile_e_coyote
ID: 9818192
Naw - the error is reported by the web service (on the SqlDataAdapter.Fill call), not the UI (which is a windows forms app).
0
 
LVL 42

Expert Comment

by:frodoman
ID: 9818313
Sorry wile_e - Nothing else I can think of, but good luck solving it!
0
 
LVL 4

Author Comment

by:wile_e_coyote
ID: 9853437
Its worth an additional 250 points for me to make some progress on this.   Any takers?
0
 
LVL 4

Accepted Solution

by:
wile_e_coyote earned 0 total points
ID: 10236236
Turns out that the httpRuntime executionTimeout setting in the machine.config file on the web server was causing IIS to kill the thread after 90 seconds.   Increasing this setting resolved the problem

I'm going to request that this question be closed.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question