Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rebase API race condition #173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kgilden
Copy link

@kgilden kgilden commented Apr 11, 2019

This follows my observations raised on #160 (comment). I tried to change as little as possible, because I'm not that familiar with Python nor the intricacies of GitLab's API.

The fix is described in detail in kgilden@89207cb.

Prior to this fix marge-bot would behave as follows, when trying to
rebase a MR using GitLab's rebase API.

  1. Make API request to rebase.
  2. Immediately refetch MR info.
  3. Observe that the MR can still be rebased, immediately retry.
  4. Due to a race condition GitLab rebases again, this time
     skipping pipelines.
  5. Comment on the MR "Someone skipped the queue! Will have to
     try again...".
  6. Check the MR info again, see that the MR can be merged.
  7. Merge the MR without actually waiting for the tests to pass.

This commit addresses 2 root causes with the following measures.

  1. Sleep a bit after rebasing a branch to avoid the rebase race
     condition. Polling is also done every 5 seconds vs the previous
     case of every 1 second.
  2. To prevent the comment "Someone skipped the queue! [...]", the
     bot does not compare locally computed SHA with GitLab's SHA after
     a rebase. This check was bogous from the start, because commits
     (including rebase'd commits) include a timestamp in them so it
     is unlikely that two different rebases result in the same SHA.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant