diff --git a/Netdisco/Changes b/Netdisco/Changes index 23266f42..a8827fc2 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -9,6 +9,7 @@ * [#211] Additional check for undefined SNMP::Info instance * [#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 2.032002 - 2015-04-03 diff --git a/Netdisco/lib/App/Netdisco/JobQueue/PostgreSQL.pm b/Netdisco/lib/App/Netdisco/JobQueue/PostgreSQL.pm index c4989792..f167343f 100644 --- a/Netdisco/lib/App/Netdisco/JobQueue/PostgreSQL.pm +++ b/Netdisco/lib/App/Netdisco/JobQueue/PostgreSQL.pm @@ -107,9 +107,13 @@ sub jq_lock { try { schema('netdisco')->txn_do(sub { schema('netdisco')->resultset('Admin') - ->find($job->job, {for => 'update'}) + ->search({job => $job->job}, {for => 'update'}) ->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 # when queueing jobs of a type for all devices schema('netdisco')->resultset('Admin')->search({ @@ -119,8 +123,9 @@ sub jq_lock { action => $job->action, subaction => $job->subaction, }, {for => 'update'})->delete(); + + $happy = true; }); - $happy = true; } catch { error $_;