最近有个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.)

转载于:https://www.cnblogs.com/cloudjun/archive/2006/06/04/417035.html

server长时间运行query,Ajax刷新被block相关推荐

  1. struts2 拦截器_Struts2 execAndWait拦截器示例,用于长时间运行的动作

    struts2 拦截器 Sometimes we have long running actions where user will have to wait for final result. In ...

  2. game module 停止运行_恒温摇床长时间运行的注意事项

    2020年10月30日 11:47   来源: 杭州川一实验仪器有限公司    >>进入该公司展台 产品简介 恒温摇床具有不锈钢万用夹具.数显控温.无级调速和良好的热循环功能,是一种多用途 ...

  3. python怎么暂停运行_如何暂停长时间运行的循环?

    我有一个关于正在运行的程序的长时间问题.在本例中,我将使用Python,但它可以用于任何编程语言.在 比方说我想把所有的数字加起来,比如说10亿results = [] for i in range( ...

  4. 长时间运行app,产生anr

    app需要实时的更新当前的地址位置信息,在位置监听中进行显示出来,包括经纬的转换,距离目标,在测试几个小时内没有问题,但是在12个小时以上就出现了界面点击无响应. 解决办法 调试发现监听中耗时10ms ...

  5. php怎么创建进程,在php中为长时间运行的进程创建后台进程

    好的,请原谅我,如果这是另一个问题的重复,但在搜索后我还没有找到一个明确的答案.我基本上想要做的是让我的php web应用程序触发一些事件(如电子邮件或报告生成器)可能需要几分钟才能完成并立即将控制权 ...

  6. ios 12von服务器未响应,创造与魔法刷资源脚本ios长时间运行未响应解决

    分别添加如下代码:->PrivateSubcmdExit_Click() Me.sckClient.SendData"Exit" EndSub PrivateSubcmdLo ...

  7. java jps都卡死,java长时间运行后,jps失效

    在部署完应用后,原本jps使用的好好的,能正确的查询到自己正在运行的java程序. 但,过了一段时间后,再使用jps来查看运行的应用时,自己运行的程序都看不到,但是自己也没有关闭这些程序啊!然而使用 ...

  8. 正在从“vetur”获取代码操作_长时间运行 io.Reader 和 io.Writer 操作测算进度和估算剩余时间...

    每当我们在使用类似 io.Copy 和 ioutil.ReadAll 的工具时,比如我们正在从 http.Response 主体读入或者上传一个文件,我们会发现这些方法将一直堵塞,直到整个过程完成,哪 ...

  9. 监控长时间运行的查询(监控数据库性能的SQL )

    查询v$session_longops动态性能视图可以查看运行时间大于6秒的查询,如果想让运行时间大于6秒的查询被数据库引擎收集,必须满足以下条件:1 参数timed_statistics或sql_t ...

最新文章

  1. Zookeeper的安装配置及基本开发
  2. 遗传算法实例-求解函数极值
  3. 埋点、数仓到中台:数据体系的从0到1
  4. azkaban mysql参数_azkaban参数详解
  5. Iphone 手机如何导入/导出通讯录
  6. 硬币支付问题(贪心策略)
  7. c++学习---继承与派生类
  8. 数据结构与算法python—6.链表及python实现
  9. elasticsearch pinyin 拼音分词器
  10. 声艺fx16调音台怎么样_声艺FX16II 声艺(Soundcraft) FX16ii 调音台
  11. 什么是Autorun病毒?它的运作原理是什么?如何手工清除?
  12. TSL1401 CCD传感器驱动
  13. 重庆涪陵创新计算机职业学校文艺表演,涪陵信息技术学校2017年元旦文艺汇演...
  14. 567个!最常用的英语动词短语搭配汇总大全!
  15. 恒峰祥可信讲述拼多多电商店铺推广和商品推广有什么不同
  16. DNS是什么意思有什么作用了
  17. 新手C语言开发详细教程
  18. ClickHouse介绍安装和工作原理(1)
  19. 解决vue重复点击路由报错问题:Uncaught (in promise) NavigationDuplicated
  20. 研二导师画大饼,不给时间实习,咋办

热门文章

  1. mysql日期格式化季度_mysql中常用日期比较与计算函数
  2. android socket 服务,android 创建socket 通信型service
  3. php屏蔽审查元素,HTML网站右键禁用F12代码 屏蔽审查元素 防止修改页面代码
  4. 自动刷新_AutoRefresh插件:开启页面自动刷新!
  5. async function_理解 Iterator, Generator 和 Async/Await
  6. 分组数据方差公式_统计学公式
  7. elasticsearch mapping之index
  8. jena dataset 增删改查
  9. Hadoop2.7.3+HBase1.2.5+ZooKeeper3.4.6搭建分布式集群环境
  10. 答应我,调试Python代码,不要再用Print了!