-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[Bug] Merged PRs have their commits and files changed metadata 'zeroed'... sometimes. #10766
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
Comments
Nope. Merged PRs are displayed by a different set of code. Lines 303 to 328 in 7225453
|
So the problem seems to be that the mergebase is incorrect - it's somehow ending up being the head! |
This means that v128.go is incorrect. The trouble is that: pr.MergeBase, err = git.NewCommand("merge-base", "--", pr.MergedCommitID+"^", gitRefName).RunInDir(repoPath) Appears to have selected the gitRefName if it's a parent of MergedCommitID instead of searching for the common root for the other parent. |
Would you reckon this is a migration problem? This has been happening on new PRs straight after merging. I tried running it in debug mode (to use breakpoints) with SQLite in VS Code on my Windows machine but hit issues around needing gcc setup properly. I may try and migrate the existing DB to MySQL before investigating further if I get time tomorrow 😃 |
It's probably the same issue if something recalculates the mergebase. |
We need to calculate the merge base from the other parents of the mergecommitid (if there are multiple parents)
Will give the commit id followed by the parents. Can get the merge base from those. Damn sorry for this bug the original code seemed to work in testing not sure why it didn't work in practice. |
EDIT: Ignore me. It was the debugger... Printing it out to the console was fine. |
Aah I think I've gotcha, so this bug will appear if the merge commit created by a PR has a parent that's also a merge commit? That would explain it not always appearing! |
-- Nope that can't happen because we check if it is an ancestor... |
Are you sure you're definitely getting this after merging PRs? Could you check what the contenst of the version table is in your DB? |
Have they been marked manually merged? |
...Marked as manually merged? We just use the big green |
In the database There's a check goroutine that has almost zero locking in 1.11 - I've mostly fixed this in master (1.12) - that goes around checking if PRs have been merged. If the checker starts during the PR merging phase and runs at or around the same as the PR being merged - it can see the commit in the git repository and think that the commit has been merged manually. At which point I could imagine it might incorrectly update the MergeBase. |
OK that means it is very likely to be the checker. |
OK so I think I've worked it out: Lines 187 to 218 in 139fc7c
This is the checker from release/v1.11. As I've said before there is a race in this code - it's possible to run this as the PR is being merged or just after it is merged. Line 203: Line 203 in 139fc7c
Calls TestPatch here: Lines 71 to 215 in 139fc7c
Which updates the pr.MergeBase - but as I say above this can end up being after the PR is merged. Finally the checker calls: Line 211 in 139fc7c
Lines 40 to 54 in 139fc7c
which will update the PR without checking if it is merged or not. The situation is similar on 1.12 but happens less frequently because we're attempting to prevent some of the raceyness. I think the answer is to change from
|
Fix go-gitea#10766 Signed-off-by: Andrew Thornton <[email protected]>
Fix go-gitea#10766 Signed-off-by: Andrew Thornton <[email protected]>
would it be possible for any of you to test those PRs? I think that they should fix the problem. |
I can try and test the backport by building a new Docker image. I'll try and report back tonight or tomorrow if it's worked. 👍 |
Fix #10766 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: guillep2k <[email protected]> Co-authored-by: Lauris BH <[email protected]>
* Only update merge_base if not already merged Fix #10766 Signed-off-by: Andrew Thornton <[email protected]> * Prevent race in transfer pull request * Update services/pull/pull.go
7 PRs down and I've not seen a zeroed one yet. Thanks Zeripath! |
Still sorry that I broke it. The broken PRs will be fixed when the migration in #10786 runs - but you might be able to backport the migration manually or fix the broken PRs in the db. In case you're interested. The correct git command for finding the merge base is: (With
|
There's nothing to be sorry about, we all make small mistakes here and there. I'm very appreciative of all the work done in an open source project - voluntary work is very respectable and I can see it being a bit of a thankless job at times. Where our team doesn't pay for Gitea (and I'm unfortunately not somebody with financial power to sponsor/donate) I can't expect a support team dedicated to fix things for me 🙂 That said I try and 'pay my debts' to the community that's helped me, so making PRs and generally improving Gitea is in my interest too. Win win! Oh, and you've also taught me about the |
you have to manualy fix them - a |
@tanrui8765 #10991 |
ok, got it, thanks~~ @6543 |
Hello friend, I deployed the gitea version V1.11.5, and tried to use Could you please tell me what to do to manually fix these problems? I'm so confused... |
|
Thank you very much @6543, it worked~ |
[x]
):Description
As of recent (within the last month I'd estimate), many PRs have their commits and files changed counters zeroed out after merging. This happens most of the time but weirdly not always on my instance now. Deleting the branch afterwards doesn't make seem to make a difference if that makes a difference.
I'm not sure how a lot of the internal Git plumbing works for Gitea so I haven't managed to take a look at the code directly. I know that #10618 seemed to be somewhat relevant - and the linked PR example in there does indeed show the behaviour below! I'm confused as to why this is shown for me as both branches definitely still exist.
Screenshots
The text was updated successfully, but these errors were encountered: