cq.uuid,
cq.task_type as taskType,
cq.component_uuid as componentUuid,
cq.main_component_uuid as mainComponentUuid,
cq.status as status,
cq.submitter_uuid as submitterUuid,
cq.worker_uuid as workerUuid,
cq.started_at as startedAt,
cq.created_at as createdAt,
cq.updated_at as updatedAt
order by
cq.created_at asc,
cq.id asc
order by
cq.created_at desc,
cq.id desc
from
ce_queue cq
and cq.main_component_uuid in
#{mainComponentUuid,jdbcType=VARCHAR}
and cq.status in
#{status,jdbcType=VARCHAR}
and cq.task_type=#{query.type,jdbcType=VARCHAR}
and cq.created_at >= #{query.minSubmittedAt,jdbcType=BIGINT}
cq.uuid as "uuid",
cq.created_at as "created_at",
cq.id as "id"
from
ce_queue cq
where
cq.status='PENDING'
and cq.started_at is null
and not exists (
select
1
from
ce_queue cq2
where
cq.main_component_uuid=cq2.main_component_uuid
and cq2.status <> 'PENDING'
)
order by
created_at asc,
id asc
insert into ce_queue
(
uuid,
task_type,
component_uuid,
main_component_uuid,
status,
submitter_uuid,
worker_uuid,
execution_count,
created_at,
updated_at,
started_at
)
values (
#{uuid,jdbcType=VARCHAR},
#{taskType,jdbcType=VARCHAR},
#{componentUuid,jdbcType=VARCHAR},
#{mainComponentUuid,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR},
#{submitterUuid,jdbcType=VARCHAR},
#{workerUuid,jdbcType=VARCHAR},
0,
#{createdAt,jdbcType=BIGINT},
#{updatedAt,jdbcType=BIGINT},
#{startedAt,jdbcType=BIGINT}
)
update ce_queue set
status='PENDING',
updated_at=#{updatedAt,jdbcType=BIGINT}
where
status <> 'PENDING'
and worker_uuid = #{workerUuid,jdbcType=VARCHAR}
update ce_queue set
status=#{new.status,jdbcType=VARCHAR},
worker_uuid=#{new.workerUuid,jdbcType=VARCHAR},
started_at=#{new.startedAt,jdbcType=BIGINT},
updated_at=#{new.updatedAt,jdbcType=BIGINT}
where
uuid=#{uuid,jdbcType=VARCHAR}
and status=#{old.status,jdbcType=VARCHAR}
delete from
ce_queue
where
uuid=#{uuid,jdbcType=VARCHAR}
and status = #{deleteIf.expectedStatus,jdbcType=VARCHAR}
update ce_queue set
status='PENDING',
worker_uuid=NULL,
updated_at=#{updatedAt,jdbcType=BIGINT}
where
status = 'IN_PROGRESS'
and (
worker_uuid is NULL
or worker_uuid not in
#{workerUUID,jdbcType=VARCHAR}
)
update ce_queue set
status='PENDING',
worker_uuid=NULL,
updated_at=#{updatedAt,jdbcType=BIGINT}
where
status = 'IN_PROGRESS'