Skip to content

Commit

Permalink
recursive job group state n_jobs and no migration transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
jigold committed Feb 8, 2024
1 parent 3ffdfae commit 70e4d7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
11 changes: 8 additions & 3 deletions batch/sql/estimated-current.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1094,13 +1094,18 @@ BEGIN
n_jobs = n_jobs + expected_n_jobs
WHERE id = in_batch_id;

### FIXME FIXME what should the state be of nested job groups
UPDATE job_groups
INNER JOIN (
SELECT batch_id, job_group_id, CAST(COALESCE(SUM(n_jobs), 0) AS SIGNED) AS staged_n_jobs
SELECT batch_id, ancestor_id, COALESCE(SUM(staged_n_jobs), 0) AS staged_n_jobs
FROM job_groups_inst_coll_staging
INNER JOIN LATERAL (
SELECT batch_id, ancestor_id
FROM job_group_self_and_ancestors
WHERE job_group_self_and_ancestors.batch_id = job_groups_inst_coll_staging.batch_id AND
job_group_self_and_ancestors.job_group_id = job_groups_inst_coll_staging.job_group_id
) AS t ON TRUE
WHERE batch_id = in_batch_id AND update_id = in_update_id
GROUP BY batch_id, job_group_id
GROUP BY batch_id, ancestor_id
) AS t ON job_groups.batch_id = t.batch_id AND job_groups.job_group_id = t.job_group_id
SET `state` = 'running', time_completed = NULL, n_jobs = n_jobs + t.staged_n_jobs;

Expand Down
15 changes: 8 additions & 7 deletions batch/sql/finalize-job-groups.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
START TRANSACTION;

DROP TRIGGER IF EXISTS batches_after_update;

SET foreign_key_checks = 0;
Expand Down Expand Up @@ -465,13 +463,18 @@ BEGIN
n_jobs = n_jobs + expected_n_jobs
WHERE id = in_batch_id;

### FIXME FIXME what should the state be of nested job groups
UPDATE job_groups
INNER JOIN (
SELECT batch_id, job_group_id, CAST(COALESCE(SUM(n_jobs), 0) AS SIGNED) AS staged_n_jobs
SELECT batch_id, ancestor_id, COALESCE(SUM(staged_n_jobs), 0) AS staged_n_jobs
FROM job_groups_inst_coll_staging
INNER JOIN LATERAL (
SELECT batch_id, ancestor_id
FROM job_group_self_and_ancestors
WHERE job_group_self_and_ancestors.batch_id = job_groups_inst_coll_staging.batch_id AND
job_group_self_and_ancestors.job_group_id = job_groups_inst_coll_staging.job_group_id
) AS t ON TRUE
WHERE batch_id = in_batch_id AND update_id = in_update_id
GROUP BY batch_id, job_group_id
GROUP BY batch_id, ancestor_id
) AS t ON job_groups.batch_id = t.batch_id AND job_groups.job_group_id = t.job_group_id
SET `state` = 'running', time_completed = NULL, n_jobs = n_jobs + t.staged_n_jobs;

Expand Down Expand Up @@ -760,5 +763,3 @@ BEGIN
END $$

DELIMITER ;

COMMIT;

0 comments on commit 70e4d7f

Please sign in to comment.