Improved job cancelation and fixed minor bugs

This commit is contained in:
Daniel García Aubert 2015-12-31 17:01:06 +01:00
parent 35650985db
commit 534da04270
2 changed files with 5 additions and 6 deletions

View File

@ -70,9 +70,9 @@ Batch.prototype._consume = function consume(host, queue, callback) {
callback();
})
.on('error', function (err) {
console.error('Error in job %s due to', job_id, err.message || err);
console.error('Error in job %s due to:', job_id, err.message || err);
self.emit('job:failed', job_id);
callback(err);
callback();
});
});
};

View File

@ -28,7 +28,7 @@ JobCanceller.prototype.cancel = function (job_id) {
}
if (job.status !== 'running') {
return jobBackend.emit('error', new Error('Job has been dispatched previously, nothing to do'));
return jobBackend.emit('error', new Error('Job is ' + job.status + ' nothing to do'));
}
self.userDatabaseMetadataService.getUserMetadata(job.user, function (err, userDatabaseMetadata) {
@ -47,12 +47,11 @@ JobCanceller.prototype.cancel = function (job_id) {
return jobBackend.emit('error', err);
}
var pid = result.rows[0].pid;
if (!pid) {
if (!result.rows[0] || result.rows[0].pid) {
return jobBackend.emit('error', new Error('Query not running currently'));
}
var pid = result.rows[0].pid;
var cancelQuery = 'SELECT pg_cancel_backend(' + pid +')';
pg.query(cancelQuery, function (err, result) {