@@ -398,20 +398,19 @@ def poll_for_completion(run_at: 1.minute.from_now)
398398 log_to_mixpanel # log before queuing file for deletion to preserve properties
399399 # don't delete files or notify users if this is a 'special action', like DE or image pipeline jobs
400400 subject = "Error: #{ study_file . file_type } file: '#{ study_file . upload_file_name } ' parse has failed"
401- retry_job = should_retry?
402- handle_ingest_failure ( subject , retry_job : ) unless special_action?
401+ handle_ingest_failure ( subject ) unless ( special_action? || should_retry? )
402+
403403 admin_email_content = generate_error_email_body ( email_type : :dev )
404- if retry_job && params_object &.next_machine_type
404+ if should_retry? && params_object &.next_machine_type
405405 new_machine = params_object . next_machine_type
406406 params_object . machine_type = new_machine
407- cloned_file = study_file . clone
408- # free up filename and other values so cloned_file can save properly, including deleting nested documents
409- # this prevents Frozen BSON::Document error
410- DeleteQueueJob . prepare_file_for_deletion ( study_file . id )
411- cloned_file . update! ( parse_status : 'parsing' )
412- file_identifier = "#{ cloned_file . upload_file_name } :#{ cloned_file . id } (#{ study . accession } )"
407+ # run a selective cleanup to allow file to retry ingest on the next machine type
408+ # this leaves any prior ingested valid data in place, and only removes data associated with this exact run
409+ DeleteQueueJob . prepare_file_for_retry ( study_file , action , cluster_name : params_object . try ( :name ) )
410+ study_file . update! ( parse_status : 'parsing' )
411+ file_identifier = "#{ study_file . upload_file_name } :#{ study_file . id } (#{ study . accession } )"
413412 Rails . logger . info "Retrying #{ action } after #{ exit_code } failure for #{ file_identifier } with machine_type: #{ new_machine } "
414- retry_job = IngestJob . new ( study :, study_file : cloned_file , user :, params_object :, action :, persist_on_fail :)
413+ retry_job = IngestJob . new ( study :, study_file :, user :, params_object :, action :, persist_on_fail :)
415414 retry_job . push_remote_and_launch_ingest
416415 # notify admins that the parse failed for visibility purposes
417416 SingleCellMailer . notify_admin_parse_fail ( user . email , subject , admin_email_content ) . deliver_now
@@ -428,7 +427,7 @@ def poll_for_completion(run_at: 1.minute.from_now)
428427 # will automatically clean up data and notify user
429428 # in case of subsampling, only subsampled data cleanup is run and all other data is left in place
430429 # this reduces churn for study owners as full-resolution data is still valid
431- def handle_ingest_failure ( email_subject , retry_job : false )
430+ def handle_ingest_failure ( email_subject )
432431 if action . to_sym == :ingest_subsample
433432 study_file . update ( parse_status : 'parsed' ) # reset parse flag
434433 cluster_name = cluster_name_by_file_type
@@ -439,17 +438,15 @@ def handle_ingest_failure(email_subject, retry_job: false)
439438 create_study_file_copy
440439 study_file . update ( parse_status : 'failed' )
441440 DeleteQueueJob . new ( study_file ) . delay . perform
442- unless persist_on_fail || retry_job
441+ unless persist_on_fail
443442 ApplicationController . firecloud_client . delete_workspace_file ( study . bucket_id , study_file . bucket_location )
444443 study_file . bundled_files . each do |bundled_file |
445444 ApplicationController . firecloud_client . delete_workspace_file ( study . bucket_id , bundled_file . bucket_location )
446445 end
447446 end
448447 end
449- unless retry_job
450- user_email_content = generate_error_email_body
451- SingleCellMailer . notify_user_parse_fail ( user . email , email_subject , user_email_content , study ) . deliver_now
452- end
448+ user_email_content = generate_error_email_body
449+ SingleCellMailer . notify_user_parse_fail ( user . email , email_subject , user_email_content , study ) . deliver_now
453450 end
454451
455452 # TODO (SCP-4709, SCP-4710) Processed and Raw expression files
0 commit comments