 
       IF `done`
       THEN
+        COMMIT;
         LEAVE READ_LOOP;
       END IF;
-
-      START TRANSACTION;
 
       SELECT `j`.`id`
       INTO `new_job_id`


      IF `done`
      THEN
        LEAVE READ_LOOP;
      END IF;

      START TRANSACTION;

      SELECT `j`.`id`
      INTO `new_job_id`

        `cluster_id`,
        `command_id`
      FROM `jobs_320`;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET `done` = TRUE;

    OPEN `jobs_cursor`;
    READ_LOOP: LOOP
      START TRANSACTION;
      SET `done` = FALSE;

      FETCH `jobs_cursor`
