You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EXECUTE 'SELECT count(*) FROM at_jobs_submitted WHERE owner = session_user AND id = $1' INTO s_count USING job_id;
171
+
IF s_count >0 THEN
172
+
UPDATE at_jobs_submitted SET canceled = true WHERE"id"= job_id;
173
+
WITH moved_rows AS (DELETEfrom ONLY at_jobs_submitted a WHEREa.id= job_id RETURNING a.*) INSERT INTO at_jobs_done SELECT*, NULLas start_time, false as status, 'job was canceled'as reason FROM moved_rows;
174
+
RETURN true;
175
+
ELSE
176
+
EXECUTE 'SELECT count(*) FROM at_jobs_process WHERE owner = session_user AND id = $1' INTO s_count USING job_id;
177
+
IF s_count >0 THEN
178
+
UPDATE at_jobs_process SET canceled = true WHERE"id"= job_id;
179
+
RETURN true;
180
+
END IF;
181
+
END IF;
182
+
183
+
RETURN false;
184
+
END
185
+
$BODY$
186
+
LANGUAGE plpgsql
187
+
SECURITY DEFINER set search_path FROM CURRENT;
188
+
189
+
164
190
CREATEFUNCTIONsubmit_job(
165
191
query text,
166
192
params text[] default NULL,
@@ -1283,7 +1309,7 @@ CREATE VIEW job_status AS
1283
1309
id, node, name, comments, at as run_after,
1284
1310
do_sql as query, params, depends_on, executor as run_as, attempt,
1285
1311
resubmit_limit, postpone as max_wait_interval,
1286
-
max_run_time as max_duration, submit_time,
1312
+
max_run_time as max_duration, submit_time, canceled,
1287
1313
start_time, status as is_success, reason as error, done_time,
Copy file name to clipboardExpand all lines: src/scheduler_job.c
+10-2Lines changed: 10 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -167,7 +167,7 @@ job_t *_at_get_jobs_to_do(char *nodename, int *n, int *is_error, int limit)
167
167
Oidargtypes[2] = { TEXTOID, INT4OID };
168
168
Datumvalues[2];
169
169
/* const char *get_job_sql = "select id, at, last_start_available, max_run_time, executor from ONLY at_jobs_submitted where at <= 'now' and (last_start_available is NULL OR last_start_available > 'now') AND node = $1 order by at, submit_time limit $2"; */
170
-
constchar*get_job_sql="select id, at, last_start_available, max_run_time, executor from ONLY at_jobs_submitted s where ((not exists ( select * from ONLY at_jobs_submitted s2 where s2.id = any(s.depends_on)) AND not exists ( select * from ONLY at_jobs_process p where p.id = any(s.depends_on)) AND s.depends_on is NOT NULL and s.at IS NULL) OR ( s.at IS NOT NULL AND at <= 'now' and (last_start_available is NULL OR last_start_available > 'now'))) and node = $1 order by at, submit_time limit $2";
170
+
constchar*get_job_sql="select id, at, last_start_available, max_run_time, executor from ONLY at_jobs_submitted s where ((not exists ( select * from ONLY at_jobs_submitted s2 where s2.id = any(s.depends_on)) AND not exists ( select * from ONLY at_jobs_process p where p.id = any(s.depends_on)) AND s.depends_on is NOT NULL and s.at IS NULL) OR ( s.at IS NOT NULL AND at <= 'now' and (last_start_available is NULL OR last_start_available > 'now'))) and node = $1 and not canceled order by at, submit_time limit $2";
171
171
172
172
*is_error=*n=0;
173
173
START_SPI_SNAP();
@@ -366,9 +366,17 @@ int resubmit_at_job(job_t *j, TimestampTz next)
366
366
intret;
367
367
constchar*sql="WITH moved_rows AS (DELETE from ONLY at_jobs_process a WHERE a.id = $1 RETURNING a.*) INSERT INTO at_jobs_submitted SELECT id, node, name, comments, $2, do_sql, params, depends_on, executor, owner, last_start_available, attempt +1 , resubmit_limit, postpone, max_run_time, submit_time FROM moved_rows";
0 commit comments