Skip to content

fix(pull): prevent merge from using stale approvals right after a push - #39199

Open
gomitrah wants to merge 1 commit into
go-gitea:mainfrom
gomitrah:fix/39172-stale-approval-merge-race
Open

fix(pull): prevent merge from using stale approvals right after a push#39199
gomitrah wants to merge 1 commit into
go-gitea:mainfrom
gomitrah:fix/39172-stale-approval-merge-race

Conversation

@gomitrah

@gomitrah gomitrah commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #39172

Push-triggered stale-review marking/dismissal runs in a detached
goroutine, unsynchronized with merge-time approval checks. A merge
called right after a push can land in that window and use an
approval from the previous head commit.

Both paths now acquire the existing per-PR lock
(getPullWorkingLockKey), so a merge can't proceed until any
in-flight stale-dismissal work for that PR has finished.

  • services/pull/pull.go: lock around the stale-marking/dismissal
    block in AddTestPullRequestTask
  • services/pull/check.go: lock in CheckPullMergeable before
    branch protection checks

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 1, 2026
@github-actions github-actions Bot added topic/pr Issues related to pull requests type/bug labels Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. topic/pr Issues related to pull requests type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Branch protection: stale approval dismissal is asynchronous, a merge right after a push succeeds with an approval given on the previous head

2 participants