mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-25 18:59:12 +02:00
Added some more error handling into MongoDB Logstream
This commit is contained in:
parent
791ac1901a
commit
27d65d30ab
@ -1558,9 +1558,22 @@ class LogStreamMongoDB extends LogStream {
|
||||
if ( ($res = $this->CreateQueryArray($uID)) != SUCCESS )
|
||||
return $res;
|
||||
|
||||
// Append LIMIT clause
|
||||
// $szSql .= " LIMIT " . $this->_currentRecordStart . ", " . $this->_logStreamConfigObj->RecordsPerQuery;
|
||||
$myCursor = $this->_myMongoCollection->find($this->_myMongoQuery, $this->_myMongoFields); // ->limit(10); // $collection->find();
|
||||
try
|
||||
{
|
||||
// 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!
|
||||
// OutputDebugMessage("LogStreamMongoDB|ReadNextRecordsFromDB: myCursor->info() = <pre>" . var_export($myCursor->info(), true) . "</pre>", DEBUG_ULTRADEBUG);
|
||||
@ -1571,12 +1584,15 @@ class LogStreamMongoDB extends LogStream {
|
||||
// OutputDebugMessage("Cursor verbose: " . var_export($myCursor->explain(), true), DEBUG_DEBUG);
|
||||
$myCursor = $myCursor->sort(array("_id" => -1));
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// Copy rows into the buffer!
|
||||
$iBegin = $this->_currentRecordNum;
|
||||
$mongoidprev = -1;
|
||||
foreach ($myCursor as $mongoid => $myRow)
|
||||
{
|
||||
// echo $this->convBaseHelper($mongoid, '0123456789abcdef', '0123456789') . "-" . $mongoid . "<br>";
|
||||
// echo $this->convBaseHelper($mongoid, '0123456789abcdef', '0123456789') . "-" . $mongoid . "<br>";
|
||||
|
||||
// Check if result was successfull! Compare the queried uID and the MONGOID to abort processing if the same ID was returned! Otherwise we have dupplicated results at the end
|
||||
if ( $myRow === FALSE || !$myRow )
|
||||
@ -1599,6 +1615,15 @@ class LogStreamMongoDB extends LogStream {
|
||||
$this->bufferedRecords[$iBegin] = array_change_key_case( $myRow, CASE_LOWER);
|
||||
$iBegin++;
|
||||
}
|
||||
}
|
||||
catch ( MongoCursorTimeoutException $e )
|
||||
{
|
||||
// Log error!
|
||||
$this->PrintDebugError("ReadNextRecordsFromDB Timeout while operation ' " . $e->getMessage() . " '");
|
||||
|
||||
// Return error code
|
||||
return ERROR_DB_TIMEOUTFAILED;
|
||||
}
|
||||
|
||||
// Uncomment for debug!
|
||||
// OutputDebugMessage("LogStreamMongoDB|ReadNextRecordsFromDB: bufferedRecords = Array <pre>" . var_export($this->bufferedRecords, true) . "</pre>", DEBUG_ULTRADEBUG);
|
||||
|
@ -78,5 +78,7 @@ define('ERROR_DB_TRIGGERFAILED', 29);
|
||||
define('ERROR_DB_CHECKSUMERROR', 30);
|
||||
define('ERROR_DB_CHECKSUMCHANGEFAILED', 31);
|
||||
define('ERROR_DB_ADDDBFIELDFAILED', 32);
|
||||
define('ERROR_DB_TIMEOUTFAILED', 33);
|
||||
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user