I am developing an application that has a big database and it waits a bit long for the result from a few queries. Sometimes, users refreshes interface before the execution is finished. There are ten users and this scenario occurs so many times.I think scripts do not stop running on sql when the web page is refreshed (becuase performance decrasing so much after a few hours). If so, Can I stop the execution of the script when the page is refreshed. In web.config, will changing Connect Timeout attibute stop the execution and rollback operations on database after timeout period is passed? Or Is there any other option in web.config file?
No connection timeout property is meant to set the timeout after which the attempt to connect to the SQL server fails. What you need is a command timeout for your stored procedure. If you share your code, expect more help.
Related
My ASP.NET application is making a database call (stored procedure) to fetch data from SQL server. The number of records to process is large and operation is going to take long time. IIS times out the request after default executionTimeout (110 seconds) which is completely fine in my case. My real question is what happens to the query that is running on the SQL server? Does IIS send any command like abort to sql server to stop the query execution?
Command timeout (300 seconds) set on the stored procedure call from ADO.NET is way more than http request execution timeout (110 seconds).
I found this and this but they do not have the answer what I'm looking for.
This article explains about how a client sends an abort command to server after command timeout has reached.
The client here is asp.net application in my case. So, IIS has to notify asp.net application that request has reached it max time and then asp.net application signals sql server to abort the executing query. Is that how it works or Am I totally understanding this topic wrong?
This is what I have tried so far running locally using Visual studio 2017 and IIS express: Set executionTimeout="30" and debug = "false" in web.config file. In stored procedure I set WAITFOR DELAY '00:05:00' for the query to run longer than http request time out. But the web request never timed out. It is waiting for the query to complete.
We have an ASP.Net web application on IIS7 that is used to upload Excel files and then load them into a SQL database by running jobs on the SQL server. The app will wait until the job completes then show the user a message. Due to some larger files being used the app is throwing the error below.
Network Error (tcp_error)
A communication error occurred: "" The Web Server may be down, too
busy, or experiencing other problems preventing it from responding to
requests. You may wish to try again at a later time. For assistance,
contact your network support team.
The app uses an asp:View to progress from various steps. I have tried to bump the session timeout and httpRuntime executionTimeout values to account for how long the job takes to run but it does not appear to have any effect. I know the job completes but the app isn't showing that feedback to the user. I think the error is thrown as the app hits the logic to display the user the view showing all the final messages.
I can only guess that a) there is another setting I'm not aware of for timeout, b) another config file setting is overruling my web config setting for the app, or c) the asp:View is counting all the various steps as one long process and not reseting the "clock" as each step is completed.
As I said, the file upload fine, and the job completes fine, the app just can't advance to that last step where it shows the user the view upon the end. Any ideas on what I can look for to fix this issue? My only other option would be to rewrite the app to not wait for the job to finish and handle notifying the user some other way.
Update 1
After further testing it appears the error is from the ASP.Net custom code we created that does a SQL bulk copy and not the running of the SQL job. The current test runs around 220 seconds testing locally but causes a timeout on a test server.
Update 2
After more research I'm inclinded to think user pevgeniev is correct and this is just a limiting factor of the browser. The only thing that prevents me from marking this as answered is I don't know why file uploads don't appear to have the same issue.
If you're getting this error in the browser, than the timeout is on the client side, and there isn't much you could do server side. As you've suggested, you could rewrite the app, so that it polls for the result from the client, rather than expecting to finish the task in a single request.
I am loading 100,000 plus pieces of data, which should take like 30 to 40 minutes to analyze and complete. We use SQL Server 2005. Currently after a specified time (trying to get the minutes it uses), the SQL Server says the connection was reset.
Is there some setting where this can be changed so my queries can run for an hour?
SqlCommand.CommandTimeout property will let you set it in code, however unless you've got clever you could get a webserver timeout as well.
Connection reset could even be your network boys, killing it for no activity.
I'd be looking at reorgansiing this somehow. Like a request to do the work and kick off athread to do it. A status page to see where it's at. When finished provides a link to the result, or somesuch.
May be your problem is related to Worker Process(w3wp.exe). In web application After some time the worker process will be recycle. So please check this setting of "IIS". you can also reset the the timeout of "Connection Timeout" in web.config or change "CommandTimeout" in code.
I have a ongoing issue with my website, where it appears the W3wp.exe crashes and in turn anyone attempting to connect to the site will receive a SQL server timeout error.
The error is this...
System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
What actually happens is when this occurs, the CPU usage on the server maxes out to 100% and stays there. During this time if I try and connect to the homepage the site will appear to be loading and then timeout. This is also the case when i try and connect to the database through management studio.
I get the above SQL timeout error from ELMAH when it emails me exceptions. When I do a iisreset I can once again connect to SQL server and the CPU usage drops immediately.
Now I have already posted a few questions oh here about the issue in regards to the SQL time out exception. So ill list what I have done and what im using...
• Im using Linq to SQL.
• SQLCacheDependancy.
• IIS 7.5 & SQL Server 2008 R2.
• Disposing of all objects.
• The call to the Linq to SQL dataContext is always wrapped in a USING Keyword.
These timeout errors occur infrequently, maybe once every 2 days, but today when I got up, my inbox was full of time out exceptions indicating one occurred overnight.
The other odd thing is that when for example it happened last night, it was around 4am, when I tried it this morning at 8am the site worked fine, so I appears that overtime the W3wp.exe, SQL server or both manage to either recycle or reset themselves.
Can anyone see what maybe causing this behaviour ? or point me in the right direction of what maybe the cause ? or perhaps even a possible solution ?
Any help is most appreciated
Truegilly
I would guess the timeout is because of the high CPU spike, not the other way round. If your IIS and SQL are on the same machine, try to find out the process (from task manager) which is hogging the processor.
If it is the web server, setup perform counters, especially the ones related to .NET Garbage collection, and see how frequently it is getting executed. Also check the Gen2 object size. You would have to collect this data starting from when it is running fine till CPU maxes out, and compare what is "growing" in the counters. Check if you have object tracking enabled in the data context, and also how long your using(datacontext){ ... } are.
If it is the sqlserver that is holding the CPU, then try to use the following Microsoft article to analyze the issue.
The architecture of the application is straight forward. There is a web application which maintain account holder data. This data is processed and the status of account holders is updated based on number of business rules. This process is initiated using a button on the page and is a long running process (say 15 mins). A component is developed to do this data processing which internally calls stored procedures. Most of the business rules are kept in stored procedure.
To handle timeouts the processing is done asynchornously(using Thread Pool or custom thread or Async Callback Delegates). The entire process run under a transaction. I would like to know your view on what happens to the transaction if the app pool is recycled or the worker process is terminated forcefully?
I'm going to assume you're using a SQL database like SQL Server, MySQL or Oracle.
These database platforms have their own internal transactional model. When you communicate with them and initiate a transaction, the server manages the transaction for you.
For a transaction to commit, the database has to be told by the client to commit the changes. If the transaction never receives this instruction, the transaction remains in a "pending" state. Eventually, after the transaction is "pending" without any further instructions, the server will consider it "dead" and will abandon it, perform a rollback on the transaction.
This is the worst-case scenario for transaction-handling, as a pending transaction may (depending on isolation level) cause resources in the database (rows, pages, entire tables) to be unavailable. Normally you see this when a network connection has failed mid-transaction (e.g. from power loss) and the client does not send the "close connection" command to the server.
If your application is terminated by having the Application Pool recycled whilst in the middle of working against the database during a transaction, the connection to the database will be closed. This act of closing the connection should cause the server to abandon any pending transactions associated with the connection.
The exact behaviour will depend on the specific database and configuration.
In either case, your database's data will remain intact.
If the worker process is terminated, I think application rollbacks.
But you have to test.