SQL 2000 (MSDE) 在从经典 ASP Web 应用程序接收到错误查询时挂起
我的经典 ASP Web 应用程序中有一个 SQL 接口页面,允许管理员用户对应用程序的数据库 (MSDE 2000) 运行查询 - 它仅包含用户提交的文本区域,应用程序返回结果记录列表,如下
Dim oRS
Set oRS = Server.CreateObject("ADODB.Recordset")
oRS.ActiveConnection = sConnectionString
// run the query - this is for the admin only so doesnt check for sql safe commands etc.
oRS.Open Request.Form("txtSQL")
If Not oRS.EOF Then
// list the field names from the recordset
For i = 0 to oRS.Fields.Count - 1
Response.Write oRS.Fields(i).name & " "
Next
// show the data for each record in the recordset
While Not oRS.EOF
For i = 0 to oRS.Fields.Count - 1
Response.Write oRS.Fields(i).value & " "
Next
Response.Write "<br />"
oRS.Movenext()
Wend
End If
所示这样做的问题是,如果你向它发送一个无效的查询(带有拼写错误、无效的连接等),它不会立即返回错误,而是会挂起 IIS(你可以通过尝试从另一台计算机浏览该应用程序来看到这一点),它会挂起 IIS。失败)几分钟,然后返回错误。我不知道为什么!有人可以帮忙吗?
I have a SQL interface page in my classic ASP web app that allows admin users to run queries against the app's database (MSDE 2000) - it simply consists of a textarea that the user submits and the app returns the resulting list of records as below
Dim oRS
Set oRS = Server.CreateObject("ADODB.Recordset")
oRS.ActiveConnection = sConnectionString
// run the query - this is for the admin only so doesnt check for sql safe commands etc.
oRS.Open Request.Form("txtSQL")
If Not oRS.EOF Then
// list the field names from the recordset
For i = 0 to oRS.Fields.Count - 1
Response.Write oRS.Fields(i).name & " "
Next
// show the data for each record in the recordset
While Not oRS.EOF
For i = 0 to oRS.Fields.Count - 1
Response.Write oRS.Fields(i).value & " "
Next
Response.Write "<br />"
oRS.Movenext()
Wend
End If
The problem with this is that if you send it an invalid query (with a spelling mistake, invalid join etc.) instead of throwing back an error immediately, it hangs IIS (you can see this by trying to browse the app from another computer, it fails) for a number of minutes and THEN returns the error. I have NO idea why! Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,在 MS 支持部门工作时,我曾经遇到过类似的请求。并不是说你也在做同样的事情,但请询问类似的故事,这可能会带来一些启发。
我接到一个来自印度的外部支持中心的晋升电话,该中心提供 ASP 支持(他施加了足够的压力,使其晋升为 SQL Server 3 级游行支持服务 - “最后一道防线”)。在网站上,SQL Server 将停止响应特定的 SQL 查询。服务器将停止执行任何操作,实际上甚至 IIS 也无法再正常使用。我从一个非常热心的同事那里得到了一个完整的案例,他甚至设法证明 SQL Server 出了问题,因为(C++ 级别)堆栈跟踪显示 OleDB 驱动程序挂在对 SQL Server 的调用中。我一生中第一次有人向我展示用于证明 SQL Server 崩溃的堆栈跟踪级别。
不管怎样,一些研究结果表明,最初编写该网站但仍然被试图解决混乱问题的客户解雇的程序员不应该使用 ASP,而应该提供汉堡。客户有一个特定的页面进行了大量复杂的 SQL 调用 - 并且数据库根本没有索引。基本上它会在一个非常便宜的磁盘系统上“捆绑进行十几个表扫描”。添加一些索引后,系统就可以使用了——客户继续检查整个复杂的数据库。支持人员显然有点羞愧,因为没有检查 SQL Server 实际在做什么(这会导致执行计划尴尬并立即导致 IO 停滞)。
在这里,这个故事又回到了您的脑海中;)
您说,由于一个错误的查询,IIS 停滞了几分钟。
你能验证一下吗:
* 这种情况发生在 IIS 上吗?正在做一个例子,并在 IIS 和企业管理器中进行检查?如果它也挂在企业管理器中 - 它不是 IIS。
* 它会像在应用程序中一样挂起 IIS。 IIS/其他应用程序/静态页面的其余部分仍然有效吗?
* 代码确实发生在页面中,而不是在中心元素/事件处理程序/同步连接中,因此一个挂起的访问会挂起整个应用程序吗?
* 在此事件期间 IIS 处理器负载和 SQL Server 负载在做什么?
* SQL Server 恰好不在同一台计算机上? (所以它会使计算机超载,从而也会影响 IIS)?
如果 IIS 端没有出现一些问题,我真的无法想象这种行为。
Basicalle,给我们更多的背景信息,我们应该找到它;)同时,享受我的故事。
Well, working at MS support I had a similar request once. Not saying it is you doing the same, but sou ask for stories like that, and this may shed some light.
I got a call promoted from an external support center running in india that did ASP support (and he made enough pressure it got promoted to processional support services SQL Server level 3 - the "last line of defence"). On a website, SQL Server would stop responding hitting a specific SQL Query. The Server would just stop doing anything, actually even IIS was not properly usable anymore. I got a full case documented from a very entusiastic fellow that even managed to proove it was something wrong with SQL Server because the (C++ level) stack traces showed the OleDB driver hanging in the call to SQL Server. First time in my life someone showed me that level of stack trace for prooving SQL Server crashed.
Anyhow, some research turned out - the programmer that originally wrote the site and had still been fired by the customer trying to fix the mess should not have been using ASP but serving burgers instead. Customer had that one particular page making a lot of compelx SQL calls - and the database had NO INDEX AT ALL. Basically it would go into "tying to make a dozen table scans" on a very cheap disc system. After adding even SOME indices, the system became usable - and the customer went to along quest of checking the whole complex database. The support person was obvsiouly a litle ashamed for not having checked what SQL Server was actually DOING (which would have resulted in awkward execution pland an stalled IO immediately).
And here the story comes back to you ;)
You say with a bad query, IIS stalls for minutes.
Can you validate that:
* This happens on IIS? Being making an example, and chcking in IIS and in Enterprise Manager? If it also hangs in Enterprise Manager - it it not IIS.
* It hangs IIS as in the app. Does the rest of IIS / other apps / static pages still work?
* The code does happen in a page, and not in a central element / event handler / synchronized connection so taht one hanging access hangs the whole app?
* What is IIS processor load and SQL Server load doing during that event?
* SQL Server does not happen to be on the same computer? (so it overloads the computer and thus also hits IIS)?
I can not really imagine this behavior without some issues in the IIS side.
Basicalle, give us a little more context and we should find it ;) Meanwhile, enjoy my story.