diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-06-02 00:36:04 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-06-02 19:43:32 +0300 |
commit | e4eac1fff1ba6d890f9f028dbfe47918b7876688 (patch) | |
tree | f4f08e065ca769e34c0e2139765b268c192260d2 /app/services | |
parent | a9dbda8605f2c3111c4e4775edf7f931e4260a41 (diff) |
Don’t schedule workers from inside transactions
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/destroy_service.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb index 06d8d143231..e2b2660ea71 100644 --- a/app/services/projects/destroy_service.rb +++ b/app/services/projects/destroy_service.rb @@ -7,11 +7,9 @@ module Projects DELETED_FLAG = '+deleted'.freeze def async_execute - project.transaction do - project.update_attribute(:pending_delete, true) - job_id = ProjectDestroyWorker.perform_async(project.id, current_user.id, params) - Rails.logger.info("User #{current_user.id} scheduled destruction of project #{project.path_with_namespace} with job ID #{job_id}") - end + project.update_attribute(:pending_delete, true) + job_id = ProjectDestroyWorker.perform_async(project.id, current_user.id, params) + Rails.logger.info("User #{current_user.id} scheduled destruction of project #{project.path_with_namespace} with job ID #{job_id}") end def execute @@ -62,7 +60,11 @@ module Projects if gitlab_shell.mv_repository(project.repository_storage_path, path, new_path) log_info("Repository \"#{path}\" moved to \"#{new_path}\"") - GitlabShellWorker.perform_in(5.minutes, :remove_repository, project.repository_storage_path, new_path) + + project.run_after_commit do + # self is now project + GitlabShellWorker.perform_in(5.minutes, :remove_repository, self.repository_storage_path, new_path) + end else false end |