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

Commit e3d127a

Browse files
author
Vladimir Ershov
committed
Merge commit '3f85a66b4356abb6de3b232103ae8284feefb6ff' into PGPROEE9_6_scheduler
2 parents 8c60e8f + 3f85a66 commit e3d127a

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

contrib/pgpro_scheduler/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

contrib/pgpro_scheduler/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);

contrib/pgpro_scheduler/src/scheduler_manager.c

Lines changed: 8 additions & 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

@@ -643,7 +643,14 @@ TimestampTz *scheduler_calc_next_task_time(scheduler_task_t *task, TimestampTz s
643643
return NULL;
644644
}
645645

646+
/* to avoid to set job on minute has already passed we add 1 minute */
646647
curr = start;
648+
#ifdef HAVE_INT64_TIMESTAMP
649+
curr += USECS_PER_MINUTE;
650+
#else
651+
curr += SECS_PER_MINUTE;
652+
#endif
653+
647654
nextarray = worker_alloc(sizeof(TimestampTz) * REALLOC_STEP);
648655
convert_rule_to_cron(task->rule, cron);
649656

contrib/pgpro_scheduler/test/make_test_env.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ SELECT schedule.create_job(
108108
'{
109109
"name": "Test #2: every 15 minute, not sngl transaction",
110110
"cron": "*/15 * * * *",
111-
"cron": "* * * * *",
112111
"commands": [
113112
"insert into result2 (time_mark, n, text) values (now(), 1, ''start job'')",
114113
"insert into result2 (time_mark, n, text) values (now(), 2, random_finish())"
@@ -122,7 +121,6 @@ SELECT schedule.create_job(
122121
'{
123122
"name": "Test #3: 2/3 minute, sngl transaction",
124123
"cron": "*/15 * * * *",
125-
"cron": "* * * * *",
126124
"commands": [
127125
"insert into result3 (time_mark, n, text) values (now(), 1, ''start job'')",
128126
"insert into result3 (time_mark, n, text) values (now(), 2, random_finish())"

0 commit comments

Comments
 (0)