Skip to content

Commit 2f160bf

Browse files
author
Vladimir Ershov
committed
vanish at works
1 parent c795670 commit 2f160bf

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pgpro_scheduler--2.0.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ BEGIN
192192
USING HINT = 'you cannot use ''run_after'' and ''depends_on'' parameters at the same time';
193193
END IF;
194194

195-
IF max_wait_interval IS NOT NULL AND run_after IS NULL THEN
195+
IF max_wait_interval IS NOT NULL AND run_after IS NOT NULL THEN
196196
last_avail := run_after + max_wait_interval;
197197
ELSE
198198
last_avail := NULL;

src/scheduler_manager.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,8 +1177,13 @@ int scheduler_vanish_expired_jobs(scheduler_manager_ctx_t *ctx, task_type_t type
11771177
int move_ret;
11781178
char *ts;
11791179
bool ts_hires = false;
1180+
TimestampTz *check_time;
1181+
int interval;
1182+
1183+
check_time = type == CronJob ? &(ctx->next_expire_time): &(ctx->next_at_expire_time);
1184+
interval = type == CronJob ? 30: 25;
11801185

1181-
if(ctx->next_expire_time > GetCurrentTimestamp()) return -1;
1186+
if(*check_time > GetCurrentTimestamp()) return -1;
11821187
pgstat_report_activity(STATE_RUNNING, "vanish expired tasks");
11831188
START_SPI_SNAP();
11841189
expired = type == CronJob ?
@@ -1227,7 +1232,7 @@ int scheduler_vanish_expired_jobs(scheduler_manager_ctx_t *ctx, task_type_t type
12271232
ret = 0;
12281233
}
12291234
STOP_SPI_SNAP();
1230-
ctx->next_expire_time = timestamp_add_seconds(0, 30);
1235+
*check_time = timestamp_add_seconds(0, interval);
12311236
pgstat_report_activity(STATE_IDLE, "vanish expired tasks done");
12321237

12331238
return ret;

0 commit comments

Comments
 (0)