Commit 27d21077 authored by Gary Holtz's avatar Gary Holtz

Attempt to put everything in the transaction block

parent dc91d10c
......@@ -8,7 +8,7 @@ module MergeRequests
#
class PostMergeService < MergeRequests::BaseService
def execute(merge_request)
return if merge_request.merged? # nothing to do, this worker has already run at least once
# return if merge_request.merged? # nothing to do, this worker has already run at least once
# These operations need to happen transactionally
ActiveRecord::Base.transaction do
......@@ -20,14 +20,14 @@ module MergeRequests
# Better to have duplicate notifications than no notifications.
todo_service.merge_merge_request(merge_request, current_user)
notification_service.merge_mr(merge_request, current_user)
end
# These operations are idempotent so can be safely run multiple times
close_issues(merge_request)
invalidate_cache_counts(merge_request, users: merge_request.assignees)
merge_request.update_project_counter_caches
delete_non_latest_diffs(merge_request)
cleanup_environments(merge_request)
# These operations are idempotent so can be safely run multiple times
close_issues(merge_request)
invalidate_cache_counts(merge_request, users: merge_request.assignees)
merge_request.update_project_counter_caches
delete_non_latest_diffs(merge_request)
cleanup_environments(merge_request)
end
# Anything after this point will be executed at-most-once. Less important activity only
# TODO: make all the work in here a separate sidekiq job so it can go in the transaction
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment