Avoid pathological delete mac for millions of nodes (S. Xu)

This commit is contained in:
Oliver Gorwits
2016-10-01 18:21:19 +01:00
parent 59c1d8e79e
commit 593b317d30
2 changed files with 16 additions and 15 deletions

View File

@@ -12,6 +12,7 @@
* [#279] Web sessions use cookies instead of files on disk (M. Johnson)
* Strip realm from username (B. Marshall)
* Mention netdisco-users mail list in docs (C. Goldsmith)
* Avoid pathological delete mac for millions of nodes (S. Xu)
[BUG FIXES]

View File

@@ -115,21 +115,21 @@ sub delete {
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;
$schema->resultset($set)->search({
'me.mac' => { '-in' => $schema->resultset($set)->search({
'-and' => [
-bool => 'nodes.active',
'me.mac' => { '-in' => $nodes->as_query }
]
},
{
columns => 'mac',
join => 'nodes',
group_by => 'me.mac',
having => \[ 'count(nodes.mac) = 0' ],
})->as_query,
},
})->delete;
}
foreach my $set (qw/