The server runs the query for a long time, and the Ajax refresh is blocked.

Source: Internet
Author: User
Recently, there was an asp.net program that requires a long time to query the database, tens of millions of records, and regular reports run at the same time. Therefore, it takes one or two hours to create a new submit. I set SQL timeout to an infinite number, and http request timeout to 12 hours. But I wonder why page can not be displayed appears after 1.5 hours of operation on the production server, the query in the background is still running. But it's okay to run on my desktop. You can return results in 3 or 4 hours.

OK, let's find a solution. Who calls it the production server.
The first thing that comes to mind is, of course, creating extra thread, placing the query in the background thread, and checking the information. It seems a little troublesome to use the regular async thread. Because it is a page can not be displayed error, it is estimated that if the client page can always contact the server, it will not be time out. So there is the first solution.
1) create a web page with 2 frames. one is the real aspx page which will do the quer, the other one is just a dummy page that will refresh itself every, say, 1 minute. well, it does not turn out to be very successful. the dummy refreshing page actually will stop the query aspx page for some unknown reason. so, solution #1 failed.

Then I thought about AJAX. Maybe I can use ajax to keeping talking to the server, while leaving the database query running.
2) find a quick ajax for asp.net 1.1 sample, set the javascript setTimeou () to 1 minute, and use ajax to get the current time from the server every 1 minute. then, I got the problem as the title of this article: The ajax remote call is blocked when the long running query is running. not sure how that happens, my guess is the long running query makes the browser TCP client thread busy waiting, and therefore it can not send another ajax request to the server. but anyway, that totally defeats my purpose to use ajax. maybe there is another way to correctly apply ajax in this situation, but I do not think I have the time to find that out. solution #2 failed too.
(Updated: I tried ajax.net http://www.cnblogs.com/nihgwu/archive/2006/06/04/417161.html and it works, so I am going to stick with Solution #2)

3) Now, I have to go back to the multithreading way in asp.net. fortunately, it looks like the traditional threading model still works on asp.net, so I do not have to use async thread. I am going to do this tomorrow, it looks doable after a small test, the only problem is I can not use windows integrated security to logon SQL server in the new thread. the thread's execution account is really wierd. it becomes Domain \ Machinename $. never seen that account before. so I have to use SQL server authentication instead.

(This is just to record something I encountered. And I find I am so slow typing Chinese so I switched to English .)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.