Uploaded image for project: 'Bitbucket Server'
  1. Bitbucket Server
  2. BSERV-12526

Mirroring a repository with a default branch other than master causes repository mirroring to fail

    XMLWordPrintable

    Details

      Description

      Issue Summary

      If the upstream repository does not have a master branch, and its default branch is defined differently, a mirror sync of this repository will fail.

      Steps to Reproduce

      1. Create a repository without the master branch, and set the default branch on the upstream
      2. Mirror the repository to a 7.4 mirror

      Expected Results

      The repository is mirrored with the correct default branch

      Actual Results

      The repository never successfully mirrors.

      The below exception is thrown in the atlassian-bitbucket.log file:

      2020-08-11 22:01:43,660 ERROR [farm-operation-4]  c.a.b.i.m.m.f.t.o.RetryingMirrorOperation MirrorOperation: repositoryDefaultBranchUpdate failed attempt 5/5 for request: DefaultBranchUpdateRequest{externalRepositoryId=5, newDefaultBranchId=refs/heads/development}; giving up
      com.atlassian.bitbucket.repository.NoDefaultBranchException: refs/heads/master is set as the default branch, but this branch does not exist
      	at com.atlassian.stash.internal.scm.git.RawGitAgent.resolveHead(RawGitAgent.java:230)
      	at com.atlassian.stash.internal.scm.git.DefaultGitCommandFactory$3.call(DefaultGitCommandFactory.java:322)
      	at com.atlassian.stash.internal.scm.git.DefaultGitCommandFactory$3.call(DefaultGitCommandFactory.java:318)
      	at com.atlassian.stash.internal.repository.DefaultRefService.getDefaultBranch(DefaultRefService.java:215)
      	at com.atlassian.stash.internal.repository.DefaultRefService.setDefaultBranch(DefaultRefService.java:308)
      	at jdk.internal.reflect.GeneratedMethodAccessor934.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at jdk.internal.reflect.GeneratedMethodAccessor452.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at jdk.internal.reflect.GeneratedMethodAccessor897.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at jdk.internal.reflect.GeneratedMethodAccessor934.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
      	at jdk.internal.reflect.GeneratedMethodAccessor934.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
      	at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
      	at com.atlassian.bitbucket.internal.mirroring.mirror.sync.DefaultMirrorBranchHelper.updateDefaultBranch(DefaultMirrorBranchHelper.java:59)
      	at com.atlassian.bitbucket.internal.mirroring.mirror.repository.MirrorRepositoryService.lambda$updateDefaultBranch$15(MirrorRepositoryService.java:338)
      	at com.atlassian.sal.core.transaction.HostContextTransactionTemplate$1.doInTransaction(HostContextTransactionTemplate.java:21)
      	at com.atlassian.stash.internal.sal.spi.HostContextAccessorImpl.doInTransaction(HostContextAccessorImpl.java:54)
      	at jdk.internal.reflect.GeneratedMethodAccessor578.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at com.atlassian.sal.core.transaction.HostContextTransactionTemplate.execute(HostContextTransactionTemplate.java:18)
      	at jdk.internal.reflect.GeneratedMethodAccessor573.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
      	at jdk.internal.reflect.GeneratedMethodAccessor573.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
      	at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
      	at com.atlassian.bitbucket.internal.mirroring.mirror.repository.MirrorRepositoryService.updateDefaultBranch(MirrorRepositoryService.java:331)
      	at com.atlassian.bitbucket.internal.mirroring.mirror.farm.RepositoryDefaultBranchUpdateOperation.perform(RepositoryDefaultBranchUpdateOperation.java:39)
      	at com.atlassian.bitbucket.internal.mirroring.mirror.farm.RepositoryDefaultBranchUpdateOperation.perform(RepositoryDefaultBranchUpdateOperation.java:19)
      	at com.atlassian.bitbucket.internal.mirroring.mirror.farm.topic.operation.AuthenticatedMirrorOperation.lambda$perform$0(AuthenticatedMirrorOperation.java:37)
      	at com.atlassian.stash.internal.user.DefaultEscalatedSecurityContext.call(DefaultEscalatedSecurityContext.java:59)
      	at com.atlassian.bitbucket.internal.mirroring.mirror.DefaultUpstreamUserHelper.performAsUpstreamUser(DefaultUpstreamUserHelper.java:93)
      	at com.atlassian.bitbucket.internal.mirroring.mirror.farm.topic.operation.AuthenticatedMirrorOperation.perform(AuthenticatedMirrorOperation.java:37)
      	at com.atlassian.bitbucket.internal.mirroring.mirror.farm.topic.operation.MultiThreadedMirrorOperation.lambda$perform$0(MultiThreadedMirrorOperation.java:45)
      	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
      	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:57)
      	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
      	at com.atlassian.sal.core.executor.ThreadLocalDelegateRunnable.run(ThreadLocalDelegateRunnable.java:34)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.lang.Thread.run(Thread.java:834)
      	... 69 frames trimmed
      

      Workaround

      Create a master branch in the upstream repository to allow the sync to complete. There is no need to set the master branch as default. After a successful sync the master branch can be removed.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              ephillips@atlassian.com Edward
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: