diff --git a/lib/App/Netdisco/Backend/Role/Manager.pm b/lib/App/Netdisco/Backend/Role/Manager.pm index 3c6e7e00..589371b2 100644 --- a/lib/App/Netdisco/Backend/Role/Manager.pm +++ b/lib/App/Netdisco/Backend/Role/Manager.pm @@ -21,6 +21,7 @@ sub worker_begin { debug "entering Manager ($wid) worker_begin()"; # job queue initialisation + debug "mgr ($wid): building acl hints (please be patient...)"; jq_warm_thrusters; # requeue jobs locally diff --git a/lib/App/Netdisco/JobQueue/PostgreSQL.pm b/lib/App/Netdisco/JobQueue/PostgreSQL.pm index 8940a01b..50b49875 100644 --- a/lib/App/Netdisco/JobQueue/PostgreSQL.pm +++ b/lib/App/Netdisco/JobQueue/PostgreSQL.pm @@ -57,14 +57,26 @@ sub jq_warm_thrusters { } schema('netdisco')->txn_do(sub { - $rs->search({ backend => setting('workers')->{'BACKEND'} })->delete; - $rs->populate([ - map {{ - backend => setting('workers')->{'BACKEND'}, - device => $_, - actionset => $actionset{$_}, - }} keys %actionset - ]); + $rs->search({ + backend => setting('workers')->{'BACKEND'}, + }, { for => 'update' }, )->update({ actionset => [] }); + + $rs->search({ + backend => setting('workers')->{'BACKEND'}, + deferrals => { '>' => 0 }, + }, { for => 'update' }, )->update({ deferrals => \'deferrals - 1' }); + + $rs->search({ + backend => setting('workers')->{'BACKEND'}, + actionset => { -value => [] }, + deferrals => 0, + })->delete; + + $rs->update_or_create({ + backend => setting('workers')->{'BACKEND'}, + device => $_, + actionset => $actionset{$_}, + }, { key => 'primary' }) for keys %actionset; }); }