#958 make job queue updates work reliably and atomically

This commit is contained in:
Oliver Gorwits
2023-01-11 14:59:12 +00:00
parent 15a5e05a38
commit d14c4b6726
2 changed files with 7 additions and 6 deletions

View File

@@ -3,7 +3,8 @@
[BUG FIXES]
* #953 port reconfig (vlan) fail due to missing DB column data
* #957 race condition in job queue management when deleting one job
* #957 make job queue updates work reliably and atomically
* #958 make job queue updates work reliably and atomically
2.060003 - 2022-12-14

View File

@@ -173,7 +173,7 @@ sub jq_getsome {
})->as_query,
}],
],
}, {for => 'update'})
}, { for => 'update' })
->update({ status => 'info', log => (sprintf 'duplicate of %s', $job->id) });
debug sprintf 'getsome: cancelled %s duplicate(s) of job %s', ($gone || 0), $job->id;
@@ -249,7 +249,7 @@ sub jq_defer {
# lock db row and update to show job is available
schema(vars->{'tenant'})->resultset('Admin')
->find($job->id, {for => 'update'})
->search({ job => $job->id }, { for => 'update' })
->update({ status => 'queued', started => undef });
});
$happy = true;
@@ -280,7 +280,8 @@ sub jq_complete {
}
schema(vars->{'tenant'})->resultset('Admin')
->find($job->id, {for => 'update'})->update({
->search({ job => $job->id }, { for => 'update' })
->update({
status => $job->status,
log => $job->log,
started => $job->started,
@@ -385,8 +386,7 @@ sub jq_delete {
if ($id) {
schema(vars->{'tenant'})->txn_do(sub {
my $job = schema(vars->{'tenant'})->resultset('Admin')->find($id);
$job->delete() if $job;
schema(vars->{'tenant'})->resultset('Admin')->search({ job => $id })->delete;
});
}
else {