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

Race condition causes migration failure due to SSH server creating public key table before restore code does

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • 2.1.0
    • 2.0.3
    • Database - Migration, SSH
    • None

      The following Exception is an example of the failure. Although this is tested on MySQL this is possible on any database.

      com.atlassian.activeobjects.spi.ActiveObjectsImportExportException: There was an error during import/export with plugin Atlassian Stash SSH Plugin(com.atlassian.stash.ssh-plugin) #2.0.4-SNAPSHOT (table AO_FB71B4_PUBLIC_KEY):Error executing update for SQL statement 'CREATE TABLE AO_FB71B4_PUBLIC_KEY (
          ID INTEGER AUTO_INCREMENT,
          KEY_MD5 VARCHAR(255),
          KEY_TEXT TEXT,
          USER_ID INTEGER,
          PRIMARY KEY(ID)
      ) ENGINE=InnoDB'
      	at com.atlassian.activeobjects.backup.ImportExportErrorServiceImpl.newImportExportSqlException(ImportExportErrorServiceImpl.java:30) ~[na:na]
      	at com.atlassian.activeobjects.backup.SqlUtils.onSqlException(SqlUtils.java:53) ~[na:na]
      	at com.atlassian.activeobjects.backup.SqlUtils.executeUpdate(SqlUtils.java:42) ~[na:na]
      	at com.atlassian.activeobjects.backup.ActiveObjectsTableCreator.create(ActiveObjectsTableCreator.java:84) ~[na:na]
      	at com.atlassian.activeobjects.backup.ActiveObjectsTableCreator.create(ActiveObjectsTableCreator.java:62) ~[na:na]
      	at com.atlassian.dbexporter.importer.TableDefinitionImporter.doImportNode(TableDefinitionImporter.java:50) ~[na:na]
      	at com.atlassian.dbexporter.importer.AbstractImporter.importNode(AbstractImporter.java:49) ~[na:na]
      	at com.atlassian.dbexporter.DbImporter.importData(DbImporter.java:73) ~[na:na]
      	at com.atlassian.activeobjects.backup.ActiveObjectsBackup.restore(ActiveObjectsBackup.java:158) ~[na:na]
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_31]
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_31]
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_31]
      	at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_31]
      	at com.atlassian.stash.internal.plugin.OsgiServiceProxyFactoryImpl$DynamicServiceInvocationHandler.invoke(OsgiServiceProxyFactoryImpl.java:119) ~[stash-platform-2.0.4-SNAPSHOT.jar:na]
      	at $Proxy166.restore(Unknown Source) ~[na:na]
      	at com.atlassian.stash.internal.backup.ao.ActiveObjectsBackupSource.restore(ActiveObjectsBackupSource.java:50) ~[stash-service-impl-2.0.4-SNAPSHOT.jar:na]
      	at com.atlassian.stash.internal.backup.AbstractBackupSupport.readActiveObjectsBackup(AbstractBackupSupport.java:199) ~[stash-service-impl-2.0.4-SNAPSHOT.jar:na]
      	at com.atlassian.stash.internal.backup.AbstractBackupSupport.restoreActiveObjects(AbstractBackupSupport.java:225) ~[stash-service-impl-2.0.4-SNAPSHOT.jar:na]
      	at com.atlassian.stash.internal.migration.DefaultMigrationService.restoreBackup(DefaultMigrationService.java:330) [stash-service-impl-2.0.4-SNAPSHOT.jar:na]
      	at com.atlassian.stash.internal.backup.AbstractBackupSupport.restore(AbstractBackupSupport.java:119) ~[stash-service-impl-2.0.4-SNAPSHOT.jar:na]
      	at com.atlassian.stash.internal.migration.DefaultMigrationService.performMigration(DefaultMigrationService.java:720) [stash-service-impl-2.0.4-SNAPSHOT.jar:na]
      	at com.atlassian.stash.internal.migration.DefaultMigrationService.access$100(DefaultMigrationService.java:63) [stash-service-impl-2.0.4-SNAPSHOT.jar:na]
      	at com.atlassian.stash.internal.migration.DefaultMigrationService$1.run(DefaultMigrationService.java:166) [stash-service-impl-2.0.4-SNAPSHOT.jar:na]
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [na:1.6.0_31]
      	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_31]
      	at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_31]
      	at com.atlassian.stash.internal.concurrent.StateTransferringExecutor$StateTransferringRunnable.run(StateTransferringExecutor.java:68) [stash-platform-2.0.4-SNAPSHOT.jar:na]
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [na:1.6.0_31]
      	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_31]
      	at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_31]
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) [na:1.6.0_31]
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206) [na:1.6.0_31]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_31]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_31]
      	at java.lang.Thread.run(Thread.java:680) [na:1.6.0_31]
      Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'ao_fb71b4_public_key' already exists
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.6.0_31]
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) ~[na:1.6.0_31]
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) ~[na:1.6.0_31]
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:513) ~[na:1.6.0_31]
      

      The current workaround is to shutdown your SSH server before performing the migration

              jhinch jhinch (Atlassian)
              jhinch jhinch (Atlassian)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: