[#156] Only delete node_ip and node_nbt when no active nodes reference
I'm a bit wary that this will slow things down horribly.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
* Fix for latest Dancer (YAML::XS)
|
||||
* [#160] Job Queue fatal error on num_slots
|
||||
* [#157] Device Port Log being emptied by device discover
|
||||
* [#156] Only delete node_ip and node_nbt when no active nodes reference
|
||||
|
||||
2.029012 - 2014-10-09
|
||||
|
||||
|
||||
@@ -109,9 +109,30 @@ sub delete {
|
||||
return 0E0;
|
||||
}
|
||||
else {
|
||||
# for node_ip and node_nbt *only* delete if there are no longer
|
||||
# any active nodes referencing the IP or NBT (hence 2nd IN clause).
|
||||
foreach my $set (qw/
|
||||
NodeIp
|
||||
NodeNbt
|
||||
/) {
|
||||
$schema->resultset($set)->search({
|
||||
'-and' => [
|
||||
'me.mac' => { '-in' => $nodes->as_query },
|
||||
'me.mac' => { '-in' => $schema->resultset($set)->search({
|
||||
-bool => 'nodes.active',
|
||||
},
|
||||
{
|
||||
columns => 'mac',
|
||||
join => 'nodes',
|
||||
group_by => 'me.mac',
|
||||
having => \[ 'count(nodes.mac) = 0' ],
|
||||
})->as_query,
|
||||
},
|
||||
],
|
||||
})->delete;
|
||||
}
|
||||
|
||||
foreach my $set (qw/
|
||||
NodeMonitor
|
||||
NodeWireless
|
||||
/) {
|
||||
|
||||
Reference in New Issue
Block a user