Fix db lock stopping policy apply

This commit is contained in:
Calvo 2021-12-16 10:26:45 +01:00
parent f162a8e6e1
commit 0bad3761a7
4 changed files with 25 additions and 3 deletions

View File

@ -0,0 +1,5 @@
START TRANSACTION;
ALTER TABLE `tpolicy_queue` MODIFY COLUMN `progress` int(10) NOT NULL default '0';
COMMIT;

View File

@ -578,7 +578,7 @@ CREATE TABLE IF NOT EXISTS `tpolicy_queue` (
`id_policy` int(10) unsigned NOT NULL default '0', `id_policy` int(10) unsigned NOT NULL default '0',
`id_agent` int(10) unsigned NOT NULL default '0', `id_agent` int(10) unsigned NOT NULL default '0',
`operation` varchar(15) default '', `operation` varchar(15) default '',
`progress` int(10) unsigned NOT NULL default '0', `progress` int(10) NOT NULL default '0',
`end_utimestamp` int(10) unsigned NOT NULL default 0, `end_utimestamp` int(10) unsigned NOT NULL default 0,
`priority` int(10) unsigned NOT NULL default '0', `priority` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)

View File

@ -2951,7 +2951,7 @@ CREATE TABLE IF NOT EXISTS `tpolicy_queue` (
`id_policy` int(10) unsigned NOT NULL default '0', `id_policy` int(10) unsigned NOT NULL default '0',
`id_agent` int(10) unsigned NOT NULL default '0', `id_agent` int(10) unsigned NOT NULL default '0',
`operation` varchar(15) default '', `operation` varchar(15) default '',
`progress` int(10) unsigned NOT NULL default '0', `progress` int(10) NOT NULL default '0',
`end_utimestamp` int(10) unsigned NOT NULL default 0, `end_utimestamp` int(10) unsigned NOT NULL default 0,
`priority` int(10) unsigned NOT NULL default '0', `priority` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)

View File

@ -5540,7 +5540,24 @@ sub pandora_process_policy_queue ($) {
} }
if($operation->{'operation'} eq 'apply' || $operation->{'operation'} eq 'apply_db') { if($operation->{'operation'} eq 'apply' || $operation->{'operation'} eq 'apply_db') {
enterprise_hook('pandora_apply_policy', [$dbh, $pa_config, $operation->{'id_policy'}, $operation->{'id_agent'}, $operation->{'id'}, $operation->{'operation'}]); my $policy_applied = enterprise_hook(
'pandora_apply_policy',
[
$dbh,
$pa_config,
$operation->{'id_policy'},
$operation->{'id_agent'},
$operation->{'id'},
$operation->{'operation'}
]
);
if($policy_applied == 0) {
sleep($pa_config->{'server_threshold'});
# Skip.
next;
}
} }
elsif($operation->{'operation'} eq 'delete') { elsif($operation->{'operation'} eq 'delete') {
if($operation->{'id_agent'} == 0) { if($operation->{'id_agent'} == 0) {