[go: up one dir, main page]

Skip to content

(Incident 19034) Prevent closing of merge requests that are merged

Context

During gitlab-com/gl-infra/production#19034 (closed), we got internal reports of some MRs being closed after they were merged. Also see #510562 (closed).

The state_machines declaration on the MergeRequest only allows open MRs to transition to closed. But race conditions could happen. For example:

  1. Sidekiq thread 1 loads the MR and it is open at this point
  2. Sidekiq thread 2 merges the MR
  3. Sidekiq thread 1 closes the MR and succeeds because in-memory it is still open

Proposal

  1. In Slack, we discussed it was suggested that we can add a WHERE state = open clause to the update query to prevent this. This does mean that the logic is duplicated between the state machine and the close service query.
  2. Force reading from primary when closing an MR
Edited by 🤖 GitLab Bot 🤖