Fix rebase API race condition - #173
Open
kgilden wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.