Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/sql/40-func.sql
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | create or replace function swh_scheduler_peek_no_priority_tasks (task_type text, ts timestamptz default now(), | ||||
stable | stable | ||||
as $$ | as $$ | ||||
select * from task | select * from task | ||||
where next_run <= ts | where next_run <= ts | ||||
and type = task_type | and type = task_type | ||||
and status = 'next_run_not_scheduled' | and status = 'next_run_not_scheduled' | ||||
and priority is null | and priority is null | ||||
order by next_run | order by next_run | ||||
limit num_tasks | limit num_tasks; | ||||
for update skip locked; | |||||
$$; | $$; | ||||
comment on function swh_scheduler_peek_no_priority_tasks (text, timestamptz, bigint) | comment on function swh_scheduler_peek_no_priority_tasks (text, timestamptz, bigint) | ||||
is 'Retrieve tasks without priority'; | is 'Retrieve tasks without priority'; | ||||
create or replace function swh_scheduler_nb_priority_tasks(num_tasks_priority bigint, task_priority task_priority) | create or replace function swh_scheduler_nb_priority_tasks(num_tasks_priority bigint, task_priority task_priority) | ||||
returns numeric | returns numeric | ||||
language sql stable | language sql stable | ||||
Show All 13 Lines | |||||
as $$ | as $$ | ||||
select * | select * | ||||
from task t | from task t | ||||
where t.next_run <= ts | where t.next_run <= ts | ||||
and t.type = task_type | and t.type = task_type | ||||
and t.status = 'next_run_not_scheduled' | and t.status = 'next_run_not_scheduled' | ||||
and t.priority = task_priority | and t.priority = task_priority | ||||
order by t.next_run | order by t.next_run | ||||
limit num_tasks_priority | limit num_tasks_priority; | ||||
for update skip locked; | |||||
$$; | $$; | ||||
comment on function swh_scheduler_peek_tasks_with_priority(text, timestamptz, bigint, task_priority) | comment on function swh_scheduler_peek_tasks_with_priority(text, timestamptz, bigint, task_priority) | ||||
is 'Retrieve tasks with a given priority'; | is 'Retrieve tasks with a given priority'; | ||||
create or replace function swh_scheduler_grab_ready_tasks (task_type text, ts timestamptz default now(), | create or replace function swh_scheduler_grab_ready_tasks (task_type text, ts timestamptz default now(), | ||||
num_tasks bigint default NULL) | num_tasks bigint default NULL) | ||||
Show All 21 Lines | |||||
as $$ | as $$ | ||||
select * | select * | ||||
from task t | from task t | ||||
where t.next_run <= ts | where t.next_run <= ts | ||||
and t.type = task_type | and t.type = task_type | ||||
and t.status = 'next_run_not_scheduled' | and t.status = 'next_run_not_scheduled' | ||||
and t.priority is not null | and t.priority is not null | ||||
order by t.next_run | order by t.next_run | ||||
limit num_tasks | limit num_tasks; | ||||
for update skip locked; | |||||
$$; | $$; | ||||
comment on function swh_scheduler_peek_any_ready_priority_tasks(text, timestamptz, bigint) | comment on function swh_scheduler_peek_any_ready_priority_tasks(text, timestamptz, bigint) | ||||
is 'List tasks with any priority ready for scheduling'; | is 'List tasks with any priority ready for scheduling'; | ||||
create or replace function swh_scheduler_grab_any_ready_priority_tasks ( | create or replace function swh_scheduler_grab_any_ready_priority_tasks ( | ||||
task_type text, ts timestamptz default now(), | task_type text, ts timestamptz default now(), | ||||
num_tasks bigint default NULL | num_tasks bigint default NULL | ||||
▲ Show 20 Lines • Show All 255 Lines • Show Last 20 Lines |