Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-12198

Bitbucket Pull request shows outdated commit hash after pushing.

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: High High
    • 7.12.0
    • 7.0.0
    • Pull Requests

       

      Reproduction steps:
      1) Create a branch “x” and create a pull request
      2) while True: (run these steps on a script until you notice that the hashes don’t match up)
      git commit —amend —no-edit # hashes change at this point.
      git push origin x -f
      if PR commit != the actual branch commit:
      break # found the bug

      Notes:
      When someone unrelated to the PR pushes an unrelated commit to master (as opposed to the PR branch) it seems Bitbucket goes through its ref cache and updates them. At this time the PR decides to update its commit. This puts the PR in the expected and correct state. [1]

      I suspect Bitbucket has some sort of cache or db of “ref -> sha” mapping. This mapping seems to not being updated or triggered correctly on every push.
      I suspect that the reason the scenario above [1] works because another (potentially unrelated) push is correctly updating this mapping and therefere causing PR’s to fall into a correct state.

            [BSERV-12198] Bitbucket Pull request shows outdated commit hash after pushing.

            It's not 100% clear to me what the expectations are here, from a user perspective, but if this issue was about refs/pull-requests/*/from refs not being updated after a push, that behavior was changed in 7.12 by BSERV-12284. Since then, from refs are updated eagerly whenever the source branch for a pull request changes.

            With regards to the reproduction script from the description, no matter what there would need to be some pauses/rechecks in the script for it to be valid because updating the pull request source branch is asynchronous from the push, which means some small delay (on the order of seconds, generally) should be expected. Once the pull request's source branch is updated, however, the from ref should be updated at (effectively) the same time.

            If anyone is continuing to have issues that they think are recurrences of this, and are on 7.12+, please open a support case and share a new reproduction with us so we can investigate further.

            Best regards,
            Bryan Turner
            Atlassian Bitbucket

            Bryan Turner (Inactive) added a comment - It's not 100% clear to me what the expectations are here, from a user perspective, but if this issue was about refs/pull-requests/*/from refs not being updated after a push, that behavior was changed in 7.12 by BSERV-12284 . Since then, from refs are updated eagerly whenever the source branch for a pull request changes. With regards to the reproduction script from the description, no matter what there would need to be some pauses/rechecks in the script for it to be valid because updating the pull request source branch is asynchronous from the push, which means some small delay (on the order of seconds, generally) should be expected. Once the pull request's source branch is updated, however, the from ref should be updated at (effectively) the same time. If anyone is continuing to have issues that they think are recurrences of this, and are on 7.12+, please open a support case and share a new reproduction with us so we can investigate further. Best regards, Bryan Turner Atlassian Bitbucket

            BSERV-12284 likewise describes a problem with refs/pull-requests/*. It seems BSERV-12284 is for creating a new pull request and this BSERV-12198 is for updating a preexisting pull request.

            Kalle Niemitalo added a comment - BSERV-12284 likewise describes a problem with refs/pull-requests/*. It seems BSERV-12284 is for creating a new pull request and this BSERV-12198 is for updating a preexisting pull request.

            A related problem is being discussed in JENKINS-61493.

            Kalle Niemitalo added a comment - A related problem is being discussed in JENKINS-61493 .

            Hi @bturner,

            Thanks a lot for your reply, very insightful . We use Jenkins pipelines with the Bitbucket Branch Source plugin, I vaguely suspect implementation may be too much ref-based and/or should leverage PR webhooks (e.g. source branch updated) instead. We'll consider if we can come up with a meaningful contribution there. Thanks again!

            Mikaël Geljić added a comment - Hi @bturner, Thanks a lot for your reply, very insightful . We use Jenkins pipelines with the Bitbucket Branch Source plugin , I vaguely suspect implementation may be too much ref-based and/or should leverage PR webhooks ( e.g. source branch updated) instead. We'll consider if we can come up with a meaningful contribution there. Thanks again!

            I used to but it got closed out, PS-24736

            Corey Steele added a comment - I used to but it got closed out, PS-24736

            corey26,

            Where are you looking to see "PR commit != the actual branch commit"? After pushes to either branch on a pull request, Bitbucket Server runs background processing that detects which pull requests needs updates and applies them. Especially for large instances, though, said processing can fall behind. I need more details to be able to help you. Do you happen to have a support case open in reference to this?

            m.geljic,

            refs/pull-requests/*/from is updated in response to someone viewing the pull request's diff. Prior to 7.0 there were more actions that could trigger it to be updated, but with the switch from 3-way diffs to 2-way diffs the number of triggers has decreased. That said, even prior to 7.0 there were no guarantees about the timeliness of updates to from refs.

            Is your CI being notified by some sort of webhook? Perhaps you're using a Marketplace app? My guess would be the 2-way diff changes in 7.0 are evading whatever technique was previously being used to try and force from refs to update.

            Best regards,
            Bryan Turner
            Atlassian Bitbucket

            Bryan Turner (Inactive) added a comment - corey26 , Where are you looking to see "PR commit != the actual branch commit"? After pushes to either branch on a pull request, Bitbucket Server runs background processing that detects which pull requests needs updates and applies them. Especially for large instances, though, said processing can fall behind. I need more details to be able to help you. Do you happen to have a support case open in reference to this? m.geljic , refs/pull-requests/*/from is updated in response to someone viewing the pull request's diff. Prior to 7.0 there were more actions that could trigger it to be updated, but with the switch from 3-way diffs to 2-way diffs the number of triggers has decreased. That said, even prior to 7.0 there were no guarantees about the timeliness of updates to from refs. Is your CI being notified by some sort of webhook? Perhaps you're using a Marketplace app? My guess would be the 2-way diff changes in 7.0 are evading whatever technique was previously being used to try and force from refs to update. Best regards, Bryan Turner Atlassian Bitbucket

            Hi there,

            Since upgrade to Bitbucket 7 (7.0.1 actually), we experience a similar bug: PR ref from the canonical repo is out-of-sync with head ref from the fork/branch. Should be filed as Bug.

            A quick way to diagnose this is through git ls-remote:

            git ls-remote --heads ssh://{host}/~user/fork.git
            <correct-sha1>    refs/heads/my-pr-branch
            git ls-remote ssh://{host}/project/repo.git refs/pull-requests/*
            <outdated-sha1>   refs/pull-requests/78/from

            This currently breaks our CI integration.

            Mikaël Geljić added a comment - Hi there, Since upgrade to Bitbucket 7 (7.0.1 actually), we experience a similar bug: PR ref from the canonical repo is out-of-sync with head ref from the fork/branch. Should be filed as Bug. A quick way to diagnose this is through git ls-remote: git ls-remote --heads ssh://{host}/~user/fork.git <correct-sha1>    refs/heads/my-pr-branch git ls-remote ssh://{host}/project/repo.git refs/pull-requests/* <outdated-sha1>   refs/pull-requests/78/from This currently breaks our CI integration.

              Unassigned Unassigned
              4c762d6af390 Corey Steele
              Affected customers:
              16 This affects my team
              Watchers:
              24 Start watching this issue

                Created:
                Updated:
                Resolved: