Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f72cc9

Browse files
author
Vladimir Ershov
committed
fix execution window
1 parent3f85a66 commit2f72cc9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

‎src/scheduler_manager.c

Lines changed: 10 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, start_date, end_date 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

@@ -413,6 +413,8 @@ scheduler_task_t *scheduler_get_active_tasks(scheduler_manager_ctx_t *ctx, int *
413413
{
414414
tasks[i].has_next_time_statement= false;
415415
}
416+
tasks[i].date1=get_timestamp_from_spi(NULL,i,6,0);
417+
tasks[i].date2=get_timestamp_from_spi(NULL,i,7,0);
416418
}
417419
*nt=processed;
418420
}
@@ -622,6 +624,11 @@ TimestampTz *scheduler_calc_next_task_time(scheduler_task_t *task, TimestampTz s
622624

623625
*ntimes=0;
624626

627+
if(task->date1>0&&task->date1>stop)returnNULL;
628+
if(task->date1>0&&task->date1>start)start=task->date1;
629+
if(task->date2>0&&task->date2<start)returnNULL;
630+
if(task->date2>0&&task->date2<stop)stop=task->date2;
631+
625632
if(first_time&&jsonb_has_key(task->rule,"onstart"))
626633
{
627634
*ntimes=1;
@@ -643,6 +650,8 @@ TimestampTz *scheduler_calc_next_task_time(scheduler_task_t *task, TimestampTz s
643650
returnNULL;
644651
}
645652

653+
654+
646655
/* to avoid to set job on minute has already passed we add 1 minute */
647656
curr=start;
648657
#ifdefHAVE_INT64_TIMESTAMP

‎src/scheduler_manager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ typedef struct {
2323
TimestampTzpostpone;
2424
TimestampTznext;
2525
boolhas_next_time_statement;
26+
TimestampTzdate1;
27+
TimestampTzdate2;
2628
}scheduler_task_t;
2729

2830
typedefenum {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp