server長時間運行query,Ajax重新整理被block

來源:互聯網
上載者:User
最近有個asp.net程式,需要長時間查 詢資料庫,千萬級,且經常有reports同時運行,所以搞不好一個submit就要等1,2個小時。我把sql timeout設成無限,http request timeout設成12個小時,但是不知為什麼在production server上總是運行了1.5小時後就出現page can not be displayed,背景query則還在運行。但是在我的desktop上運行就沒問題,3,4個小時也可以return results.

OK,那就想辦法吧,誰叫那是production server呢。
第一個想到的當然是建立extra thread,把那個query放到背景thread裡去,查了查資料,用正規的async thread來做好像有點麻煩。因為是page can not be displayed error, 於是想到如果client page能夠時時的聯絡一下server,估計就不會time out.於是就有了第一個方案。
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.)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.