         `cluster_id`,
         `command_id`
       FROM `jobs_320`;
-    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
+    DECLARE CONTINUE HANDLER FOR NOT FOUND SET `done` = TRUE;
 
     OPEN `jobs_cursor`;
     READ_LOOP: LOOP
+      START TRANSACTION;
       SET `done` = FALSE;
 
       FETCH `jobs_cursor`

        `application_id`,
        `application_order`
      FROM `jobs_applications_320`;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

    OPEN `jobs_applications_cursor`;
    READ_LOOP: LOOP
      SET `done` = FALSE;

      FETCH `jobs_applications_cursor`


      IF `done`
      THEN
        COMMIT;
        LEAVE READ_LOOP;
      END IF;

      SELECT `cl`.`id`
      INTO `new_cluster_id`
