Make sure producers always release agent locks.
A MySQL error that didn't bring the server down could result in a consumer returning without releasing its agent lock.
This commit is contained in:
parent
2c047cb401
commit
a200362ffe
|
@ -304,21 +304,22 @@ sub data_consumer ($$) {
|
||||||
agent_unlock($pa_config, $agent_name);
|
agent_unlock($pa_config, $agent_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink ($file_name);
|
unlink ($file_name);
|
||||||
if (defined($xml_data->{'server_name'})) {
|
|
||||||
process_xml_server ($self->getConfig (), $file_name, $xml_data, $self->getDBH ());
|
eval {
|
||||||
} elsif (defined($xml_data->{'connection_source'})) {
|
if (defined($xml_data->{'server_name'})) {
|
||||||
enterprise_hook('process_xml_connections', [$self->getConfig (), $file_name, $xml_data, $self->getDBH ()]);
|
process_xml_server ($self->getConfig (), $file_name, $xml_data, $self->getDBH ());
|
||||||
} elsif (defined($xml_data->{'ipam_source'})) {
|
} elsif (defined($xml_data->{'connection_source'})) {
|
||||||
enterprise_hook('process_xml_ipam', [$self->getConfig (), $file_name, $xml_data, $self->getDBH ()]);
|
enterprise_hook('process_xml_connections', [$self->getConfig (), $file_name, $xml_data, $self->getDBH ()]);
|
||||||
} elsif (defined($xml_data->{'network_matrix'})){
|
} elsif (defined($xml_data->{'ipam_source'})) {
|
||||||
process_xml_matrix_network(
|
enterprise_hook('process_xml_ipam', [$self->getConfig (), $file_name, $xml_data, $self->getDBH ()]);
|
||||||
$self->getConfig(), $xml_data, $self->getDBH()
|
} elsif (defined($xml_data->{'network_matrix'})){
|
||||||
);
|
process_xml_matrix_network( $self->getConfig(), $xml_data, $self->getDBH());
|
||||||
} else {
|
} else {
|
||||||
process_xml_data ($self->getConfig (), $file_name, $xml_data, $self->getServerID (), $self->getDBH ());
|
process_xml_data ($self->getConfig (), $file_name, $xml_data, $self->getServerID (), $self->getDBH ());
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
agent_unlock($pa_config, $agent_name);
|
agent_unlock($pa_config, $agent_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1174,15 +1175,6 @@ sub process_xml_matrix_network {
|
||||||
sub agent_lock {
|
sub agent_lock {
|
||||||
my ($pa_config, $dbh, $agent_name) = @_;
|
my ($pa_config, $dbh, $agent_name) = @_;
|
||||||
|
|
||||||
# Do not lock on LIFO mode if the agent already exist.
|
|
||||||
# get_agent_id will be called again from process_xml_data,
|
|
||||||
# so the should be no race conditions if the agent does
|
|
||||||
# not exist.
|
|
||||||
if ($pa_config->{'dataserver_lifo'} == 1 &&
|
|
||||||
get_agent_id ($dbh, $agent_name) > 0) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$AgentSem->down ();
|
$AgentSem->down ();
|
||||||
if (defined ($Agents{$agent_name})) {
|
if (defined ($Agents{$agent_name})) {
|
||||||
$AgentSem->up ();
|
$AgentSem->up ();
|
||||||
|
|
Loading…
Reference in New Issue