[#217] find changed to search to handle missing row in queue

This commit is contained in:
Oliver Gorwits
2015-05-05 18:53:41 +01:00
parent ee4a27a6bf
commit 8239918772
2 changed files with 8 additions and 2 deletions

View File

@@ -9,6 +9,7 @@
* [#211] Additional check for undefined SNMP::Info instance * [#211] Additional check for undefined SNMP::Info instance
* [#212] Discover SQL error on returning multiple rows * [#212] Discover SQL error on returning multiple rows
* [#217] find changed to search to handle missing row in queue
* Re-set hostname on device after renumber * Re-set hostname on device after renumber
2.032002 - 2015-04-03 2.032002 - 2015-04-03

View File

@@ -107,9 +107,13 @@ sub jq_lock {
try { try {
schema('netdisco')->txn_do(sub { schema('netdisco')->txn_do(sub {
schema('netdisco')->resultset('Admin') schema('netdisco')->resultset('Admin')
->find($job->job, {for => 'update'}) ->search({job => $job->job}, {for => 'update'})
->update({ status => "queued-$fqdn" }); ->update({ status => "queued-$fqdn" });
return unless
schema('netdisco')->resultset('Admin')
->count({job => $job->job, status => "queued-$fqdn"});
# remove any duplicate jobs, needed because we have race conditions # remove any duplicate jobs, needed because we have race conditions
# when queueing jobs of a type for all devices # when queueing jobs of a type for all devices
schema('netdisco')->resultset('Admin')->search({ schema('netdisco')->resultset('Admin')->search({
@@ -119,8 +123,9 @@ sub jq_lock {
action => $job->action, action => $job->action,
subaction => $job->subaction, subaction => $job->subaction,
}, {for => 'update'})->delete(); }, {for => 'update'})->delete();
$happy = true;
}); });
$happy = true;
} }
catch { catch {
error $_; error $_;