Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7e974b5

Browse files
author
Vladimir Ershov
committed
fix execution window, get_log SELECT + OUTER JOIN && bgworker_restart time
1 parent 62b316b commit 7e974b5

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

pgpro_scheduler--2.0.sql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,12 @@ DECLARE
284284
cron_id INTEGER;
285285
BEGIN
286286
cron_id := NEW.id;
287-
IF NOT NEW.active OR NEW.broken OR NEW.rule <> OLD.rule OR NEW.postpone <> OLD.postpone THEN
287+
IF NOT NEW.active OR NEW.broken OR
288+
coalesce(NEW.rule <> OLD.rule, true) OR
289+
coalesce(NEW.postpone <> OLD.postpone, true) OR
290+
coalesce(NEW.start_date <> OLD.start_date, true) OR
291+
coalesce(NEW.end_date <> OLD.end_date, true)
292+
THEN
288293
DELETE FROM at WHERE cron = cron_id AND active = false;
289294
END IF;
290295
RETURN OLD;
@@ -1206,9 +1211,9 @@ BEGIN
12061211
END IF;
12071212

12081213
IF usename = '___all___' THEN
1209-
sql_cmd := 'SELECT * FROM log as l , cron as cron WHERE cron.id = l.cron';
1214+
sql_cmd := 'SELECT * FROM log as l LEFT OUTER JOIN cron ON cron.id = l.cron';
12101215
ELSE
1211-
sql_cmd := 'SELECT * FROM log as l , cron as cron WHERE cron.executor = ''' || usename || ''' AND cron.id = l.cron';
1216+
sql_cmd := 'SELECT * FROM log as l LEFT OUTER JOIN cron ON cron.executor = ''' || usename || ''' AND cron.id = l.cron';
12121217
END IF;
12131218

12141219
FOR ii IN EXECUTE sql_cmd LOOP

src/pgpro_scheduler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ pg_scheduler_startup(void)
408408
worker.bgw_flags = BGWORKER_SHMEM_ACCESS |
409409
BGWORKER_BACKEND_DATABASE_CONNECTION;
410410
worker.bgw_start_time = BgWorkerStart_ConsistentState;
411-
worker.bgw_restart_time = BGW_NEVER_RESTART;
411+
worker.bgw_restart_time = 10;
412412
worker.bgw_main = NULL;
413413
worker.bgw_notify_pid = 0;
414414
worker.bgw_main_arg = Int32GetDatum(0);

src/scheduler_manager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ scheduler_task_t *scheduler_get_active_tasks(scheduler_manager_ctx_t *ctx, int *
378378

379379
*nt = 0;
380380
initStringInfo(&sql);
381-
appendStringInfo(&sql, "select id, rule, postpone, _next_exec_time, next_time_statement from cron where active and not broken and (start_date <= 'now' or start_date is null) and (end_date <= 'now' or end_date is null) and node = '%s'", ctx->nodename);
381+
appendStringInfo(&sql, "select id, rule, postpone, _next_exec_time, next_time_statement from cron where active and not broken and (start_date <= 'now' or start_date is null) and (end_date >= 'now' or end_date is null) and node = '%s'", ctx->nodename);
382382

383383
pgstat_report_activity(STATE_RUNNING, "select 'at' tasks");
384384

0 commit comments

Comments
 (0)