Merge Request: Possible to have source branched removed *BEFORE* merge occurs
Created by: sroth80021
On GitLab 2.8, we recently saw an especially nasty bug, which seems to be a race condition in GitLab.
In short, a user went to process a merge request, and selected the 'remove source branch' checkbox. Then they clicked Accept Merge Request.
Unfortunately, the branch was removed JUST BEFORE the merge was attempted.
In other words, their branch was never merged into the master branch, and was also removed from the server. Fortunately, I was able to reconstruct the branch from some client-side state, but given how nasty this was, I wanted to enter an issue.
This is the ordering we see in the GitLab production.log and the Gitolite logs, indicating this sequence of events:
FROM GITLAB: MERGE REQUEST ACCEPTED
Started GET "/foo_main_bar/merge_requests/42/automerge?utf8=%E2%9C%93&should_remove_source_branch=1&commit=Accept+Merge+Request" for 127.0.0.1 at 2012-09-13 02:56:06 -0700 Processing by MergeRequestsController#automerge as JS Parameters: {"utf8"=>"✓", "should_remove_source_branch"=>"1", "commit"=>"Accept Merge Request", "project_id"=>"foo_main_bar", "id"=>"42"} Rendered merge_requests/automerge.js.haml (0.2ms) Completed 200 OK in 1961ms (Views: 2.0ms | ActiveRecord: 20.3ms)
FROM GITOLITE: DELETE BRANCH
2012-09-13.09:56:07 2080 pre_git foo_main_bar gitlab W any -> refs/.* 2012-09-13.09:56:07 2080 system,git,shell,-c,git-receive-pack '/scratch/git/repositories/foo_main_bar.git' 2012-09-13.09:56:07 2080 update,foo_main_bar,gitlab,+,refs/heads/reorder,4254d567f05f64f147aa1278843509f2e3f70947,0000000000000000000000000000000000000000 2012-09-13.09:56:07 2080 -> refs/.* 2012-09-13.09:56:07 2080 update foo_main_bar gitlab + refs/heads/reorder 4254d567f05f64f147aa1278843509f2e3f70947 0000000000000000000000000000000000000000 2012-09-13.09:56:07 2080 END
FROM GITOLITE: PUSH TO MASTER BRANCH
2012-09-13.09:56:08 2135 ssh ARGV=gitlab SOC=git-receive-pack 'foo_main_bar.git' FROM=10.234.12.34 2012-09-13.09:56:08 2135 access(foo_main_bar, gitlab, W, 'any'),-> refs/.* 2012-09-13.09:56:08 2135 trigger,Writable,access_1,ACCESS_1,foo_main_bar,gitlab,W,any,refs/.* 2012-09-13.09:56:08 2135 pre_git foo_main_bar gitlab W any -> refs/.* 2012-09-13.09:56:08 2135 system,git,shell,-c,git-receive-pack '/scratch/git/repositories/foo_main_bar.git' 2012-09-13.09:56:08 2135 update,foo_main_bar,gitlab,W,refs/heads/master,bcdacbf00660f7df0611ba19f21a3ed5308a9b57,455abee1e6a18c47aa95a35a2d72dd8f4d179a72 2012-09-13.09:56:08 2135 die VREF/update: helper program exit status 256 2012-09-13.09:56:08 2135 END