MigrationException when migrating to a MySQL database
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
While trying to migrate Bitbucket Server database to MySQL via UI it fails and the following appears in the atlassian-bitbucket.log:
2015-06-29 19:00:00,000 ERROR [threadpool:thread-1052] admin @1LR5NQ2x1172x39161x1 xzgmic 127.0.0.1,0:0:0:0:0:0:0:1 "POST /admin/db/edit HTTP/1.1" c.a.s.i.m.m.BaseMigrationTask Reverting database configuration after a failed migration attempt
com.atlassian.bitbucket.internal.migration.MigrationException: Backup of Active Objects data from /opt/bitbucket-home/tmp/backup-admin-20150630-003316-417Z.zip-unpack2131549050436166442.backup/active-objects-data.xml could not be restored.
at com.atlassian.bitbucket.internal.maintenance.restore.ActiveObjectsRestoreStep.run(ActiveObjectsRestoreStep.java:73) ~[bitbucket-service-impl-3.8.0.jar:na]
at com.atlassian.bitbucket.internal.maintenance.CompositeMaintenanceTask$Step.run(CompositeMaintenanceTask.java:130) ~[bitbucket-service-impl-3.8.0.jar:na]
at com.atlassian.bitbucket.internal.maintenance.CompositeMaintenanceTask.run(CompositeMaintenanceTask.java:69) ~[bitbucket-service-impl-3.8.0.jar:na]
at com.atlassian.bitbucket.internal.maintenance.restore.RestorePhase.run(RestorePhase.java:26) ~[bitbucket-service-impl-3.8.0.jar:na]
at com.atlassian.bitbucket.internal.maintenance.CompositeMaintenanceTask$Step.run(CompositeMaintenanceTask.java:130) ~[bitbucket-service-impl-3.8.0.jar:na]
at com.atlassian.bitbucket.internal.maintenance.CompositeMaintenanceTask.run(CompositeMaintenanceTask.java:69) ~[bitbucket-service-impl-3.8.0.jar:na]
at com.atlassian.bitbucket.internal.maintenance.CompositeMaintenanceTask$Step.run(CompositeMaintenanceTask.java:130) ~[bitbucket-service-impl-3.8.0.jar:na]
at com.atlassian.bitbucket.internal.maintenance.CompositeMaintenanceTask.run(CompositeMaintenanceTask.java:69) ~[bitbucket-service-impl-3.8.0.jar:na]
at com.atlassian.bitbucket.internal.maintenance.MaintenanceModePhase.run(MaintenanceModePhase.java:27) ~[bitbucket-service-impl-3.8.0.jar:na]
at com.atlassian.bitbucket.internal.maintenance.migration.BaseMigrationTask.run(BaseMigrationTask.java:67) ~[bitbucket-service-impl-3.8.0.jar:na]
at com.atlassian.bitbucket.internal.maintenance.migration.DatabaseMigrationTask.run(DatabaseMigrationTask.java:49) [bitbucket-service-impl-3.8.0.jar:na]
at com.atlassian.bitbucket.internal.maintenance.DefaultMaintenanceTaskMonitor.run(DefaultMaintenanceTaskMonitor.java:191) [bitbucket-service-impl-3.8.0.jar:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_71]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_71]
at com.atlassian.bitbucket.internal.concurrent.StateTransferringExecutor$StateTransferringRunnable.run(StateTransferringExecutor.java:73) [bitbucket-platform-3.8.0.jar:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_71]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_71]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) [na:1.7.0_71]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) [na:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71]
... 1 frame trimmed
Caused by: com.atlassian.activeobjects.spi.ActiveObjectsImportExportException: There was an error during import/export with plugin Atlassian Bitbucket Server Audit Log Plugin(com.atlassian.bitbucket.bitbucket-audit) #3.8.0 (table AO_BD73C3_REPOSITORY_AUDIT):Could not import data in table 'AO_BD73C3_REPOSITORY_AUDIT' column #4, value is too big for column which size limit is 431, value is:
{"project":"PROJECT","repository":"repo","hook":"be.foreach.bitbucket.notifier:my-post-receive-repository-hook","settings":{"branchFilter":"","mailNotification":"true","mailToAddress":"admin@bitbucket.com","mailOverrideFrom":"false","mailFromTemplate":"","mailOverrideSubject":"false","mailSubjectTemplate":"","mailOverrideBody":"false","mailBodyTemplate":"","slackWebHookUrl":"","slackChannels":""}}
at com.atlassian.activeobjects.backup.ImportExportErrorServiceImpl.newImportExportException(ImportExportErrorServiceImpl.java:24) ~[na:na]
at com.atlassian.dbexporter.importer.DataImporter$BaseInserter.setString(DataImporter.java:388) ~[na:na]
at com.atlassian.dbexporter.importer.DataImporter$BaseInserter.setValue(DataImporter.java:436) ~[na:na]
at com.atlassian.dbexporter.importer.DataImporter.importTable(DataImporter.java:125) ~[na:na]
at com.atlassian.dbexporter.importer.DataImporter.access$000(DataImporter.java:35) ~[na:na]
at com.atlassian.dbexporter.importer.DataImporter$1.call(DataImporter.java:75) ~[na:na]
at com.atlassian.dbexporter.importer.DataImporter$1.call(DataImporter.java:64) ~[na:na]
at com.atlassian.dbexporter.jdbc.JdbcUtils.withConnection(JdbcUtils.java:31) ~[na:na]
at com.atlassian.dbexporter.importer.DataImporter.doImportNode(DataImporter.java:63) ~[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:161) ~[na:na]
at com.atlassian.bitbucket.internal.plugin.OsgiServiceProxyFactoryImpl$DynamicServiceInvocationHandler.invoke(OsgiServiceProxyFactoryImpl.java:119) ~[bitbucket-platform-3.8.0.jar:na]
at com.atlassian.bitbucket.internal.maintenance.restore.ActiveObjectsRestoreStep.run(ActiveObjectsRestoreStep.java:63) ~[bitbucket-service-impl-3.8.0.jar:na]
... 21 common frames omitted
Diagnosis
Environment
- The issue occurs for MySQL database, with Bitbucket Server using a driver up to version
mysql-connector-java-5.1.14
.
Diagnostic Steps
- Check the size of the columns of varchar type of the AO tables in the old and the new database, confirming their size is different.
Cause
A bug in the database driver causes the size of the columns to change, thus the migration fails.
Resolution
Change the MySQL driver used by Bitbucket Server to a version higher than 5.1.14:
- Stop Bitbucket Server.
- Move the
mysql-connector-java-5.1.XX-bin.jar
driver from<Bitbucket home directory>/lib
to a backup location.- We want to make sure that only 1 version of the driver file exists in the lib directory.
- Download the latest driver from http://dev.mysql.com/downloads/connector/j/ to
<Bitbucket home directory>/lib
. - Start Bitbucket Server.
- Attempt the database migration again.