Last modified: 2007-09-26 04:31:28 UTC
When the DBs are under heavy load, it's possible to get the API to return 'internal_api_error' when a connection to the DB fails. It would be nice if this error code was changed to something distinctive, because users will need to detect this condition and retry the request, and right now that seems to require parsing the 'info' parameter of the error code, not just the 'code' parameter. Here's a dump of the error message object I received. 'error' => { 'code' => 'internal_api_error', 'info' => 'Exception Caught: DB connection error: All servers busy', 'content' => ' #0 /usr/local/apache/common-local/php-1.5/includes/LoadBalancer.php(361): LoadBalancer->reportConnectionError(Object(Database)) #1 [internal function]: LoadBalancer->getConnection(-1, true, Array) #2 /usr/local/apache/common-local/php-1.5/includes/StubObject.php(32): call_user _func_array(Array, Array) #3 /usr/local/apache/common-local/php-1.5/includes/StubObject.php(40): StubObject->_call(\'getConnection\', Array) #4 [internal function]: StubObject->__call(\'getConnection\', Array) #5 /usr/local/apache/common-local/php-1.5/includes/GlobalFunctions.php(2285): StubObject->getConnection(-1, true, Array) #6 /usr/local/apache/common-local/php-1.5/includes/api/ApiQuery.php(119): wfGetDB(-1) #7 /usr/local/apache/common-local/php-1.5/includes/api/ApiQueryBase.php(182): ApiQuery->getDB() #8 /usr/local/apache/common-local/php-1.5/includes/api/ApiQueryBacklinks.php(136): ApiQueryBase->getDB() #9 /usr/local/apache/common-local/php-1.5/includes/api/ApiQueryBacklinks.php(93): ApiQueryBacklinks->run() #10 /usr/local/apache/common-local/php-1.5/includes/api/ApiQuery.php(196): ApiQueryBacklinks->execute() #11 /usr/local/apache/common-local/php-1.5/includes/api/ApiMain.php(306): ApiQuery->execute() #12 /usr/local/apache/common-local/php-1.5/includes/api/ApiMain.php(192): ApiMain->executeAction() #13 /usr/local/apache/common-local/php-1.5/includes/api/ApiMain.php(177): ApiMain->executeActionWithErrorHandling() #14 /usr/local/apache/common-local/php-1.5/api.php(54): ApiMain->execute() #15 /usr/local/apache/common-local/live-1.5/api.php(3): require(\'/usr/local/apac...\') #16 {main}' }
Committed r26140. Name of the exception caught now included in the error code of the message. This should be distinct enough for client-side handling (i.e., your problem will produce an error code of 'internal_api_error_SQLException', whereas others may produce 'internal_api_error_MWException', etc.).