diff --git a/batch/job_canceller.js b/batch/job_canceller.js index fb41b683..56e1a2e0 100644 --- a/batch/job_canceller.js +++ b/batch/job_canceller.js @@ -26,6 +26,10 @@ function doCancel(job_id, userDatabaseMetadata, callback) { return callback(err); } + if (!pid) { + return callback(); + } + doCancelQuery(pg, pid, function (err, isCancelled) { if (err) { return callback(err); @@ -35,7 +39,7 @@ function doCancel(job_id, userDatabaseMetadata, callback) { return callback(new Error('Query has not been cancelled')); } - callback(null); + callback(); }); }); } @@ -49,7 +53,8 @@ function getQueryPID(pg, job_id, callback) { } if (!result.rows[0] || !result.rows[0].pid) { - return callback(new Error('Query is not running currently')); + // query is not running actually, but we have to callback w/o error to cancel the job anyway. + return callback(); } callback(null, result.rows[0].pid); diff --git a/batch/job_service.js b/batch/job_service.js index 99ad458c..ea397461 100644 --- a/batch/job_service.js +++ b/batch/job_service.js @@ -36,19 +36,19 @@ JobService.prototype.list = function (user, callback) { } var jobList = dataList.map(function (data) { - var job; + var job; - try { - job = JobFactory.create(data); - } catch (err) { - return debug(err); - } + try { + job = JobFactory.create(data); + } catch (err) { + return debug(err); + } - return job; - }) - .filter(function (job) { - return job !== undefined; - }); + return job; + }) + .filter(function (job) { + return job !== undefined; + }); callback(null, jobList); });