[Phplib-commit] CVS: php-lib-stable/php db_mysql.inc,1.9,1.10
Brought to you by:
nhruby,
richardarcher
From: Richard A. <ric...@us...> - 2002-04-25 07:37:00
|
Update of /cvsroot/phplib/php-lib-stable/php In directory usw-pr-cvs1:/tmp/cvs-serv3127 Modified Files: db_mysql.inc Log Message: Patch #511458 from Thomas L. Kjeldsen Addresses two issues: nextid() does not test if mysql_query fails Under some circumstances, ie very heavy load, MySQL may fail on at simple SELECT-query. If this happens, nextid() just assumes there is no entry for $seq_name in $this->Seq_Table and tries to create a new entry. It will fail, but $currentid is set to 0 and the subsequent update will immediately set the nextid-value to 1. halt() does not unlock tables if they are locked Halt() does not unlock tables before die(). Under heavy load it seems to result in a mass use of http deamons that just end up sleeping - leaving no free http deamons after a short time. Index: db_mysql.inc =================================================================== RCS file: /cvsroot/phplib/php-lib-stable/php/db_mysql.inc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** db_mysql.inc 14 Mar 2002 20:36:43 -0000 1.9 --- db_mysql.inc 25 Apr 2002 07:36:56 -0000 1.10 *************** *** 40,44 **** var $Link_ID = 0; var $Query_ID = 0; ! /* public: constructor */ --- 40,45 ---- var $Link_ID = 0; var $Query_ID = 0; ! ! var $locked = false; ## set to true while we have a lock /* public: constructor */ *************** *** 192,199 **** --- 193,205 ---- return false; } + $this->locked = true; return true; } function unlock() { + + // set before unlock to avoid potential loop + $this->locked = false; + if(!$this->query("unlock tables")) { $this->halt("unlock() failed."); *************** *** 247,250 **** --- 253,260 ---- $seq_name); $id = @mysql_query($q, $this->Link_ID); + if (!$id) { + $this->halt('query failed in nextid: '.$q); + return 0; + } $res = @mysql_fetch_array($id); *************** *** 257,260 **** --- 267,274 ---- $currentid); $id = @mysql_query($q, $this->Link_ID); + if (!$id) { + $this->halt('query failed in nextid: '.$q); + return 0; + } } else { $currentid = $res["nextid"]; *************** *** 266,269 **** --- 280,287 ---- $seq_name); $id = @mysql_query($q, $this->Link_ID); + if (!$id) { + $this->halt('query failed in nextid: '.$q); + return 0; + } $this->unlock(); } else { *************** *** 374,377 **** --- 392,400 ---- $this->Error = @mysql_error($this->Link_ID); $this->Errno = @mysql_errno($this->Link_ID); + + if ($this->locked) { + $this->unlock(); + } + if ($this->Halt_On_Error == "no") return; |