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
/* const char *get_job_sql = "select * from at_jobs_submitted s where ((not exists ( select * from at_jobs_submitted s2 where s2.id = any(s.depends_on)) AND not exists ( select * from 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 1 FOR UPDATE SKIP LOCKED"; */
175
-
constchar*get_job_sql="select * from at_jobs_submitted s where ((not exists ( select * from at_jobs_submitted s2 where s2.id = any(s.depends_on)) AND not exists ( select * from at_jobs_process p where p.id = any(s.depends_on)) AND s.depends_on is NOT NULL and s.at IS NULL AND not exists ( select * from at_jobs_done d where d.id = any(s.depends_on) and d.status=false)) 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 1 FOR UPDATE SKIP LOCKED ";
cron.node from at at, cron cron where start_at <= 'now' and \
359
377
not at.active and (last_start_available is NULL OR \
360
378
last_start_available > 'now') and at.cron = cron.id AND cron.node ");
361
379
getNodesToSelect(&nodes, nodename);
362
-
appendStringInfo(&get_job_sql, " %s order by at.start_at limit %d", nodes.cond, limit);
380
+
appendStringInfo(get_job_sql, " %s order by at.start_at limit %d", nodes.cond, limit);
363
381
364
382
365
383
*is_error=*n=0;
@@ -390,6 +408,8 @@ job_t *_cron_get_jobs_to_do(MemoryContext mem, char *nodename, int *n, int *is_e
390
408
{
391
409
*is_error=1;
392
410
}
411
+
pfree(get_job_sql->data);
412
+
pfree(get_job_sql);
393
413
destroyNodesToSelect(&nodes);
394
414
STOP_SPI_SNAP();
395
415
returnjobs;
@@ -400,12 +420,16 @@ job_t *get_expired_at_jobs(char *nodename, int *n, int *is_error)
400
420
StringInfoDatasql;
401
421
job_t*jobs=NULL;
402
422
intret, got, i;
423
+
scheduler_nodes_data_tnodes;
403
424
404
425
*n=*is_error=0;
426
+
getNodesToSelect(&nodes, nodename);
405
427
initStringInfo(&sql);
406
-
appendStringInfo(&sql, "select at, last_start_available, id from ONLY at_jobs_submitted where last_start_available < 'now' and node = '%s'", nodename);
407
-
ret=SPI_execute(sql.data, true, 0);
428
+
appendStringInfo(&sql, "select at, last_start_available, id, node from ONLY at_jobs_submitted where last_start_available < 'now' and node %s", nodes.cond);
@@ -421,7 +445,7 @@ job_t *get_expired_at_jobs(char *nodename, int *n, int *is_error)
421
445
jobs[i].last_start_avail=get_timestamp_from_spi(NULL, i, 2, 0);
422
446
jobs[i].cron_id=scheduler_atjob_id_OID==INT8OID ?
423
447
get_int64_from_spi(NULL, i, 3, 0): get_int_from_spi(NULL, i, 3, 0);
424
-
jobs[i].node=my_copy_string(nodename);
448
+
jobs[i].node=get_text_from_spi(CurrentMemoryContext, NULL, i, 4);
425
449
}
426
450
}
427
451
}
@@ -437,12 +461,17 @@ job_t *get_expired_cron_jobs(char *nodename, int *n, int *is_error)
437
461
StringInfoDatasql;
438
462
job_t*jobs=NULL;
439
463
intret, got, i;
464
+
scheduler_nodes_data_tnodes;
440
465
441
466
*n=*is_error=0;
442
467
initStringInfo(&sql);
443
-
appendStringInfo(&sql, "select start_at, last_start_available, cron, started, active from at where last_start_available < 'now' and not active and node = '%s'", nodename);
444
-
ret=SPI_execute(sql.data, true, 0);
468
+
appendStringInfo(&sql, "select start_at, last_start_available, cron, started, active, node from at where last_start_available < 'now' and not active and node ");
0 commit comments