Download this file
| 1 | UPDATE tasks SET state='cancel_requested' |
| 2 | WHERE wait_code='task.wait.reconcile' AND EXISTS ( |
| 3 | SELECT 1 FROM audit_events a WHERE a.record_id=tasks.id AND a.kind='task.cancel'); |
| 4 | UPDATE tasks SET state=CASE WHEN state='cancel_requested' THEN 'cancelled' ELSE 'waiting' END, |
| 5 | wait_code=CASE WHEN state='cancel_requested' THEN '' ELSE 'task.wait.setup' END, revision=revision+1 |
| 6 | WHERE wait_code='task.wait.reconcile' |
| 7 | AND NOT EXISTS (SELECT 1 FROM runner_assignments a WHERE a.task_id=tasks.id AND a.protocol_version=1 AND a.claim_request!='' AND a.state!='contained') |
| 8 | AND NOT EXISTS (SELECT 1 FROM attempts a WHERE a.job_id=tasks.job_id AND a.containment='pending'); |
| 9 | UPDATE jobs SET state=CASE WHEN EXISTS (SELECT 1 FROM tasks t WHERE t.job_id=jobs.id AND t.state='cancelled') THEN 'cancelled' ELSE 'running' END, |
| 10 | wait='',revision=revision+1 |
| 11 | WHERE state='waiting' AND wait='uncertain_external_outcome' |
| 12 | AND EXISTS (SELECT 1 FROM tasks t WHERE t.job_id=jobs.id AND t.wait_code!='task.wait.reconcile') |
| 13 | AND NOT EXISTS (SELECT 1 FROM attempts a WHERE a.job_id=jobs.id AND a.containment='pending') |
| 14 | AND NOT EXISTS (SELECT 1 FROM actions a WHERE a.job_id=jobs.id AND a.state IN ('dispatching','uncertain')); |
| 15 | UPDATE task_outboxes SET state=CASE WHEN EXISTS(SELECT 1 FROM tasks t WHERE t.id=task_outboxes.task_id AND t.job_id!=0) THEN 'done' ELSE 'prepare' END |
| 16 | WHERE state='reconcile' AND EXISTS (SELECT 1 FROM tasks t WHERE t.id=task_outboxes.task_id AND t.wait_code!='task.wait.reconcile'); |
| 17 | INSERT INTO audit_events(actor,kind,record_id,at) |
| 18 | VALUES('system','system.migration.direct_reconcile','equipo/0019_direct_reconcile',CURRENT_TIMESTAMP); |
| 19 | |