mirror of https://github.com/MISP/MISP
new: [performance] Made the deadlock fix optional
- old behaviour by default or if the setting is disabled - new behaviour with non transactional attribute add / correlation addpull/3323/head
parent
d644d9411d
commit
ed09fdedbf
|
@ -272,7 +272,8 @@ class AttributesController extends AppController {
|
|||
if (!empty($successes)) {
|
||||
$this->Event->unpublishEvent($eventId);
|
||||
}
|
||||
$result = $this->Attribute->saveMany($attributes, array('atomic' => false));
|
||||
$atomic = Configure::read('MISP.deadlock_avoidance') ? false : true;
|
||||
$result = $this->Attribute->saveMany($attributes, array('atomic' => $atomic));
|
||||
if ($this->_isRest()) {
|
||||
if (!empty($successes)) {
|
||||
$attributes = $this->Attribute->find('all', array(
|
||||
|
|
|
@ -1712,62 +1712,65 @@ class Attribute extends AppModel {
|
|||
$testCorrelations = array();
|
||||
foreach ($correlatingAttributes as $k => $cA) {
|
||||
foreach ($cA as $corr) {
|
||||
$testCorrelations[] = array(
|
||||
'value' => $correlatingValues[$k],
|
||||
'1_event_id' => $event['Event']['id'],
|
||||
'1_attribute_id' => $a['id'],
|
||||
'event_id' => $corr['Attribute']['event_id'],
|
||||
'attribute_id' => $corr['Attribute']['id'],
|
||||
'org_id' => $corr['Event']['org_id'],
|
||||
'distribution' => $corr['Event']['distribution'],
|
||||
'a_distribution' => $corr['Attribute']['distribution'],
|
||||
'sharing_group_id' => $corr['Event']['sharing_group_id'],
|
||||
'a_sharing_group_id' => $corr['Attribute']['sharing_group_id'],
|
||||
'date' => $corr['Event']['date'],
|
||||
'info' => $corr['Event']['info']
|
||||
);
|
||||
$correlations[] = array(
|
||||
$correlatingValues[$k],
|
||||
$event['Event']['id'],
|
||||
$a['id'],
|
||||
$corr['Attribute']['event_id'],
|
||||
$corr['Attribute']['id'],
|
||||
$corr['Event']['org_id'],
|
||||
$corr['Event']['distribution'],
|
||||
$corr['Attribute']['distribution'],
|
||||
$corr['Event']['sharing_group_id'],
|
||||
$corr['Attribute']['sharing_group_id'],
|
||||
$corr['Event']['date'],
|
||||
$corr['Event']['info']
|
||||
);
|
||||
$testCorrelations[] = array(
|
||||
'value' => $correlatingValues[$k],
|
||||
'1_event_id' => $corr['Event']['id'],
|
||||
'1_attribute_id' => $corr['Attribute']['id'],
|
||||
'event_id' => $a['event_id'],
|
||||
'attribute_id' => $a['id'],
|
||||
'org_id' => $event['Event']['org_id'],
|
||||
'distribution' => $event['Event']['distribution'],
|
||||
'a_distribution' => $a['distribution'],
|
||||
'sharing_group_id' => $event['Event']['sharing_group_id'],
|
||||
'a_sharing_group_id' => $a['sharing_group_id'],
|
||||
'date' => $event['Event']['date'],
|
||||
'info' => $event['Event']['info']
|
||||
);
|
||||
$correlations[] = array(
|
||||
$correlatingValues[$k],
|
||||
$corr['Event']['id'],
|
||||
$corr['Attribute']['id'],
|
||||
$a['event_id'],
|
||||
$a['id'],
|
||||
$event['Event']['org_id'],
|
||||
$event['Event']['distribution'],
|
||||
$a['distribution'],
|
||||
$event['Event']['sharing_group_id'],
|
||||
$a['sharing_group_id'],
|
||||
$event['Event']['date'],
|
||||
$event['Event']['info']
|
||||
);
|
||||
if (Configure::read('MISP.deadlock_avoidance')) {
|
||||
$correlations[] = array(
|
||||
'value' => $correlatingValues[$k],
|
||||
'1_event_id' => $event['Event']['id'],
|
||||
'1_attribute_id' => $a['id'],
|
||||
'event_id' => $corr['Attribute']['event_id'],
|
||||
'attribute_id' => $corr['Attribute']['id'],
|
||||
'org_id' => $corr['Event']['org_id'],
|
||||
'distribution' => $corr['Event']['distribution'],
|
||||
'a_distribution' => $corr['Attribute']['distribution'],
|
||||
'sharing_group_id' => $corr['Event']['sharing_group_id'],
|
||||
'a_sharing_group_id' => $corr['Attribute']['sharing_group_id'],
|
||||
'date' => $corr['Event']['date'],
|
||||
'info' => $corr['Event']['info']
|
||||
);
|
||||
$correlations[] = array(
|
||||
'value' => $correlatingValues[$k],
|
||||
'1_event_id' => $corr['Event']['id'],
|
||||
'1_attribute_id' => $corr['Attribute']['id'],
|
||||
'event_id' => $a['event_id'],
|
||||
'attribute_id' => $a['id'],
|
||||
'org_id' => $event['Event']['org_id'],
|
||||
'distribution' => $event['Event']['distribution'],
|
||||
'a_distribution' => $a['distribution'],
|
||||
'sharing_group_id' => $event['Event']['sharing_group_id'],
|
||||
'a_sharing_group_id' => $a['sharing_group_id'],
|
||||
'date' => $event['Event']['date'],
|
||||
'info' => $event['Event']['info']
|
||||
);
|
||||
} else {
|
||||
$correlations[] = array(
|
||||
$correlatingValues[$k],
|
||||
$event['Event']['id'],
|
||||
$a['id'],
|
||||
$corr['Attribute']['event_id'],
|
||||
$corr['Attribute']['id'],
|
||||
$corr['Event']['org_id'],
|
||||
$corr['Event']['distribution'],
|
||||
$corr['Attribute']['distribution'],
|
||||
$corr['Event']['sharing_group_id'],
|
||||
$corr['Attribute']['sharing_group_id'],
|
||||
$corr['Event']['date'],
|
||||
$corr['Event']['info']
|
||||
);
|
||||
$correlations[] = array(
|
||||
$correlatingValues[$k],
|
||||
$corr['Event']['id'],
|
||||
$corr['Attribute']['id'],
|
||||
$a['event_id'],
|
||||
$a['id'],
|
||||
$event['Event']['org_id'],
|
||||
$event['Event']['distribution'],
|
||||
$a['distribution'],
|
||||
$event['Event']['sharing_group_id'],
|
||||
$a['sharing_group_id'],
|
||||
$event['Event']['date'],
|
||||
$event['Event']['info']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$fields = array(
|
||||
|
@ -1784,10 +1787,21 @@ class Attribute extends AppModel {
|
|||
'date',
|
||||
'info'
|
||||
);
|
||||
if (!empty($testCorrelations)) {
|
||||
$this->Correlation->saveMany($testCorrelations, array('atomic' => false, 'callbacks' => false, 'deep' => false, 'validate' => false, 'fieldList' => $fields));
|
||||
//$db = $this->getDataSource();
|
||||
//$db->insertMulti('correlations', $fields, $correlations);
|
||||
if (Configure::read('MISP.deadlock_avoidance')) {
|
||||
if (!empty($correlations)) {
|
||||
$this->Correlation->saveMany($correlations, array(
|
||||
'atomic' => false,
|
||||
'callbacks' => false,
|
||||
'deep' => false,
|
||||
'validate' => false,
|
||||
'fieldList' => $fields
|
||||
));
|
||||
}
|
||||
} else {
|
||||
if (!empty($correlations)) {
|
||||
$db = $this->getDataSource();
|
||||
$db->insertMulti('correlations', $fields, $correlations);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -826,6 +826,15 @@ class Server extends AppModel {
|
|||
'errorMessage' => '',
|
||||
'test' => null,
|
||||
'type' => 'string',
|
||||
),
|
||||
'deadlock_avoidance' => array(
|
||||
'level' => 1,
|
||||
'description' => 'Only enable this if you have some tools using MISP with extreme high concurency. General performance will be lower as normal as certain transactional queries are avoided in favour of shorter table locks.',
|
||||
'value' => false,
|
||||
'errorMessage' => '',
|
||||
'test' => 'testBool',
|
||||
'type' => 'boolean',
|
||||
'null' => true
|
||||
)
|
||||
),
|
||||
'GnuPG' => array(
|
||||
|
|
Loading…
Reference in New Issue