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

Pull requests are declined or updates are attributed to the wrong user

    XMLWordPrintable

Details

    Description

      In Bitbucket 4.13, the mechanism for resolving refs (determining the current commit the branch/tag references) was refactored. The new implementation does not properly handle concurrent updates to the packed-refs, which can result in the ref not resolving properly. When this happens, Bitbucket incorrectly concludes that the branch or tag does not exist.

      Symptoms

      Example stack trace:

      2017-07-17 11:40:56,120 WARN  [pull-request-rescoping:thread-1]  c.a.s.i.scm.git.ref.PackedRefDb Problem reading from packed-refs file /data/bitbucket/shared/data/repositories/12345/packed-refs (FileAlreadyExistsException: /data/bitbucket/shared/data/repositories/12345/packed-refs)
      java.nio.file.FileAlreadyExistsException: /data/bitbucket/shared/data/repositories/12345/packed-refs
      	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:88)
      	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
      	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
      	at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
      	at java.nio.file.Files.newByteChannel(Files.java:361)
      	at java.nio.file.Files.newByteChannel(Files.java:407)
      	at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
      	at java.nio.file.Files.newInputStream(Files.java:152)
      	at java.nio.file.Files.newBufferedReader(Files.java:2784)
      	at java.nio.file.Files.newBufferedReader(Files.java:2816)
      	at com.atlassian.stash.internal.scm.git.ref.PackedRefDb$PackedRefIterator.initialize(PackedRefDb.java:309)
      	at com.atlassian.stash.internal.scm.git.ref.PackedRefDb$PackedRefIterator.getNext(PackedRefDb.java:253)
      	at com.atlassian.stash.internal.scm.git.ref.PackedRefDb$PackedRefIterator.hasNext(PackedRefDb.java:237)
      	at com.atlassian.stash.internal.scm.git.ref.PackedRefDb.internalResolve(PackedRefDb.java:114)
      	at com.atlassian.stash.internal.scm.git.ref.PackedRefDb.resolve(PackedRefDb.java:71)
      	at com.atlassian.stash.internal.scm.git.ref.CompositeGitRefDb.resolve(CompositeGitRefDb.java:109)
      	at com.atlassian.stash.internal.scm.git.command.refdb.ResolveGitRefDbCommand.internalCall(ResolveGitRefDbCommand.java:54)
      	at com.atlassian.stash.internal.scm.git.command.refdb.ResolveGitRefDbCommand.internalCall(ResolveGitRefDbCommand.java:23)
      	at com.atlassian.stash.internal.scm.git.command.refdb.AbstractGitRefDbCommand.call(AbstractGitRefDbCommand.java:49)
      	at com.atlassian.stash.internal.scm.git.command.refdb.ResolveGitRefDbCommand.call(ResolveGitRefDbCommand.java:43)
      	at com.atlassian.stash.internal.scm.git.command.refdb.ResolveGitRefDbCommand.call(ResolveGitRefDbCommand.java:23)
      	at com.atlassian.stash.internal.pull.rescope.DefaultPullRequestRescopeService.resolveRefs(DefaultPullRequestRescopeService.java:352)
      	at com.atlassian.stash.internal.pull.rescope.DefaultPullRequestRescopeService.resolveRefs(DefaultPullRequestRescopeService.java:331)
      	at com.atlassian.stash.internal.pull.rescope.DefaultPullRequestRescopeService.setTargetStateOnRescopeChains(DefaultPullRequestRescopeService.java:365)
      	at com.atlassian.stash.internal.pull.rescope.DefaultPullRequestRescopeService.rescopeInternal(DefaultPullRequestRescopeService.java:281)
      	at com.atlassian.stash.internal.pull.rescope.DefaultPullRequestRescopeService.lambda$rescope$0(DefaultPullRequestRescopeService.java:117)
      	at com.atlassian.stash.internal.user.DefaultEscalatedSecurityContext.call(DefaultEscalatedSecurityContext.java:54)
      	at com.atlassian.stash.internal.pull.rescope.DefaultPullRequestRescopeService.rescope(DefaultPullRequestRescopeService.java:116)
      	at com.atlassian.stash.internal.pull.rescope.PullRequestRescopeBucketProcessor.process(PullRequestRescopeBucketProcessor.java:158)
      	at com.atlassian.stash.internal.concurrent.HazelcastBucketedExecutor$BucketProcessingBootstrapper.run(HazelcastBucketedExecutor.java:125)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.lang.Thread.run(Thread.java:745)
      	... 13 frames trimmed
      
      

      The problem is most visible when pull requests are updated as a result of an update to the source or target branch. This can result in:

      • the pull request being declined (because the source/target branch appeared to be deleted)
      • the pull request incorrectly reporting that multiple commits were removed from the pull request. This happens because the loose ref in the repository did not resolve, but an older version of the ref was present in packed-refs. To the pull request rescope process, it appears that the branch was reset to the older hash.

      Workaround

      • If the pull request was declined, it can be reopened.
      • If the pull request displays the incorrect scope, decline and reopen the pull request to refresh it.

      Attachments

        Issue Links

          Activity

            People

              mheemskerk Michael Heemskerk (Inactive)
              mheemskerk Michael Heemskerk (Inactive)
              Votes:
              6 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: