Added some more error handling into MongoDB Logstream

This commit is contained in:
Andre Lorbach 2012-05-07 15:27:26 +02:00
parent 791ac1901a
commit 27d65d30ab
2 changed files with 53 additions and 26 deletions

View File

@ -1558,9 +1558,22 @@ class LogStreamMongoDB extends LogStream {
if ( ($res = $this->CreateQueryArray($uID)) != SUCCESS ) if ( ($res = $this->CreateQueryArray($uID)) != SUCCESS )
return $res; return $res;
// Append LIMIT clause try
// $szSql .= " LIMIT " . $this->_currentRecordStart . ", " . $this->_logStreamConfigObj->RecordsPerQuery; {
$myCursor = $this->_myMongoCollection->find($this->_myMongoQuery, $this->_myMongoFields); // ->limit(10); // $collection->find(); // Debug Informations
OutputDebugMessage("LogStreamMongoDB|ReadNextRecordsFromDB: Running FIND ", DEBUG_ULTRADEBUG);
// Find Data in MongoCollection
$myCursor = $this->_myMongoCollection->find($this->_myMongoQuery, $this->_myMongoFields);
}
catch ( MongoCursorException $e )
{
// Log error!
$this->PrintDebugError("ReadNextRecordsFromDB failed with error ' " . $e->getMessage() . " '");
// Return error code
return ERROR_DB_QUERYFAILED;
}
// Uncomment for debug! // Uncomment for debug!
// OutputDebugMessage("LogStreamMongoDB|ReadNextRecordsFromDB: myCursor->info() = <pre>" . var_export($myCursor->info(), true) . "</pre>", DEBUG_ULTRADEBUG); // OutputDebugMessage("LogStreamMongoDB|ReadNextRecordsFromDB: myCursor->info() = <pre>" . var_export($myCursor->info(), true) . "</pre>", DEBUG_ULTRADEBUG);
@ -1571,6 +1584,9 @@ class LogStreamMongoDB extends LogStream {
// OutputDebugMessage("Cursor verbose: " . var_export($myCursor->explain(), true), DEBUG_DEBUG); // OutputDebugMessage("Cursor verbose: " . var_export($myCursor->explain(), true), DEBUG_DEBUG);
$myCursor = $myCursor->sort(array("_id" => -1)); $myCursor = $myCursor->sort(array("_id" => -1));
try
{
// Copy rows into the buffer! // Copy rows into the buffer!
$iBegin = $this->_currentRecordNum; $iBegin = $this->_currentRecordNum;
$mongoidprev = -1; $mongoidprev = -1;
@ -1599,6 +1615,15 @@ class LogStreamMongoDB extends LogStream {
$this->bufferedRecords[$iBegin] = array_change_key_case( $myRow, CASE_LOWER); $this->bufferedRecords[$iBegin] = array_change_key_case( $myRow, CASE_LOWER);
$iBegin++; $iBegin++;
} }
}
catch ( MongoCursorTimeoutException $e )
{
// Log error!
$this->PrintDebugError("ReadNextRecordsFromDB Timeout while operation ' " . $e->getMessage() . " '");
// Return error code
return ERROR_DB_TIMEOUTFAILED;
}
// Uncomment for debug! // Uncomment for debug!
// OutputDebugMessage("LogStreamMongoDB|ReadNextRecordsFromDB: bufferedRecords = Array <pre>" . var_export($this->bufferedRecords, true) . "</pre>", DEBUG_ULTRADEBUG); // OutputDebugMessage("LogStreamMongoDB|ReadNextRecordsFromDB: bufferedRecords = Array <pre>" . var_export($this->bufferedRecords, true) . "</pre>", DEBUG_ULTRADEBUG);

View File

@ -78,5 +78,7 @@ define('ERROR_DB_TRIGGERFAILED', 29);
define('ERROR_DB_CHECKSUMERROR', 30); define('ERROR_DB_CHECKSUMERROR', 30);
define('ERROR_DB_CHECKSUMCHANGEFAILED', 31); define('ERROR_DB_CHECKSUMCHANGEFAILED', 31);
define('ERROR_DB_ADDDBFIELDFAILED', 32); define('ERROR_DB_ADDDBFIELDFAILED', 32);
define('ERROR_DB_TIMEOUTFAILED', 33);
?> ?>