php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25859 php.exe consumes 100% cpu
Submitted: 2003-10-14 06:00 UTC Modified: 2003-10-14 20:22 UTC
From: mfelden at gsd-web dot de Assigned:
Status: Not a bug Package: IIS related
PHP Version: 4.3.2 OS: windows 2000 server
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mfelden at gsd-web dot de
New email:
PHP Version: OS:

 

 [2003-10-14 06:00 UTC] mfelden at gsd-web dot de
Description:
------------
PHP is running on the local http-server IIS. A script loaded in IE 5 causes a new instance of php.exe running on the server. It instantly consumes 100% of the cpu power. This blocks the server, so the query could not be completed. The IIS sends a Timeout after 30 seconds. I can't change it, due to the MMC which says, there is no IIS. Even after closing the IE-Window php.exe is consuming 100% of the cpu power for the next say 5 minutes. During this php.exe dis- and appears in the process list again and again. In php.ini php_iisfunc.dll is commented out.

It is no fun.

Reproduce code:
---------------
<html><head><title>Import</title></head>
<body><h3>Daten holen</h3>
<form action='daten.php' method="POST">
  <input name=ok type=submit value=OK>
</form></body></html>
<?php 
if($_POST['ok']){get_data();}
function get_data()
{ 
  $query =  "SELECT * FROM corpus WHERE gms is not null and id>590 and id<691"; 	
	$result = query($query, $source);

	for($i = 0; $i < $result->rows; $i++)
	{
    $query = "UPDATE corpus SET strasse ='" . $result->data[$i]['field'] . "' WHERE id = " . $result->data[$i]['id'];
   	query($query);
		}		
	}    
}
function query($query)
{
  $link = dbx_connect (DBX_MSSQL, "1.2.3.4", "db", "user", "pwd", DBX_PERSISTENT| DBX_RESULT_INFO) or die ("Fehler beim Verbinden");  	
  $result = dbx_query($link, $query);
  dbx_close ($link);
  return $result;
}
?>


Expected result:
----------------
Query completed

Actual result:
--------------
Timeout after 30 sec

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-14 06:20 UTC] mboeren@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

I'm assuming the select query gets a lot of data: since dbx_query retrieves and buffers all data this could lead to a very long execution time.
If this is not the case, please re-open this bug report.
Otherwise, read on:

First: alter your sql statement to only retrieve fields you actually need, such as 'field' and 'id'. Don't use * in a select statement.

Second: your query() function is not very efficient: it would be much better to put the dbx_connect() and dbx_close() calls outside the function, preferably at the beginning and end of the script or perhaps the get_data() function. And when you do that you might as well skip the query() function definition altogether :-)

If you are retrieving a lot of records, the new version of dbx_query() (in CVS only) has support for the DBX_RESULT_UNBUFFERED flag where you can retrieve data record by record, which is probably what you want as it is a lot more efficient.

If you are unable to get the CVS version, perhaps you should use the mysql_unbuffered_query() directly...

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 17:01:31 2024 UTC