Unknown Cipher Data id 0 error when upgrading from 5.13 => 5.14 => 6.6.2
Asked by Joe Bednarz:

According to a KB [note](https://confluence.atlassian.com/bamkb/unknown-cipher-data-id-0-when-performing-certain-actions-in-bamboo-on-windows-after-switching-bamboo-to-run-as-a-service-923437107.html?_ga=2.106198083.115838556.1541611226-2137980481.1508870240) this error is due to a mismatch in the cipher key(s), in count. My upgrade path is from 5.13 to 6.6.2 which dictates an interim upgrade step to 5.14 first.

A problem indicator shown in the KB says this query should return some rows:

    SELECT *   FROM BANDANAWHERE BANDANA_KEY LIKE '%cipher%';

...actually doesn't return ANY rows... I do see the generated file in the OS, so perhaps I just need a way to generate the SQL record?

Need some help because at this point I have a broken Bamboo server.

-Joe Bednarz


Answers:
author: Alexey Chystoprudov
body: Do you have logs from upgrade process? Did 5.14 version work for you after upgrade?

comments: author: Foong
body: Created Support Ticket


author: Joe Bednarz
body: Thank you for your replies. Yes, 5.14 upgrade worked without any issues. Started fine, checked build jobs, etc. Unfortunately, the network this instance of Bamboo operates on is air-gapped so getting the log files uploaded involves a file transfer, or good old-fashioned transcription. Can be done, just takes a while...

-Joe


author: Joe Bednarz
body: I got the log file over. I see that the start of the upgrade starts here:

2018-11-07 13:44:03,414 INFO \[localhost-startStop-1\] \[BambooContainer\] Plugin system available, after 20.23 s  
2018-11-07 13:44:03,414 INFO \[localhost-startStop-1\] \[XWorkPluginConfigurationMaintainer\] Reloading Struts configuration (Struts configuration reloads enabled)...  
2018-11-07 13:44:03,414 INFO \[localhost-startStop-1\] \[XWorkPluginConfigurationMaintainer\] Struts configuration reloaded (Struts configuration reloads enabled).  
2018-11-07 13:44:03,414 INFO \[localhost-startStop-1\] \[UpgradeLauncher\] Initialisation completed.  
2018-11-07 13:44:03,414 INFO \[localhost-startStop-1\] \[UpgradeLauncher\] Current data is at build number: 51504. Upgrade required. Firing upgrade manager...  
2018-11-07 13:44:03,586 INFO \[17-UpgradeTaskBackgroundThread:pool-31-thread-1\] \[UpgradeManagerImpl\] Found 0 high priority upgrade tasks  
2018-11-07 13:44:03,586 INFO \[17-UpgradeTaskBackgroundThread:pool-31-thread-1\] \[UpgradeManagerImpl\] Found 13 upgrade tasks

Then problems occur:

2018-11-07 13:44:03,586 INFO \[17-UpgradeTaskBackgroundThread:pool-31-thread-1\] \[AbstractUpgradeManager\] ------------------------------------------------------------------------  
2018-11-07 13:44:03,586 INFO \[17-UpgradeTaskBackgroundThread:pool-31-thread-1\] \[AbstractUpgradeManager\] 51505 : Encrypt secure fields of repository definitions (post-bootstrap)  
2018-11-07 13:44:03,586 INFO \[17-UpgradeTaskBackgroundThread:pool-31-thread-1\] \[AbstractUpgradeManager\] ------------------------------------------------------------------------  
2018-11-07 13:44:03,664 FATAL \[17-UpgradeTaskBackgroundThread:pool-31-thread-1\] \[InstanceSecretStorage\] Database part of instance key is unavailable  
2018-11-07 13:44:03,664 FATAL \[17-UpgradeTaskBackgroundThread:pool-31-thread-1\] \[InstanceSecretStorage\] Cipher initialisation vector is unavailable  
2018-11-07 13:44:03,664 FATAL \[17-UpgradeTaskBackgroundThread:pool-31-thread-1\] \[SecretEncryptionServiceInternalImpl\]  
java.lang.IllegalArgumentException: Unable to read cipher data for 0  
at com.atlassian.bamboo.crypto.instance.InstanceSecretStorage.readKeyAndIv(InstanceSecretStorage.java:59)  
at com.atlassian.bamboo.crypto.instance.InstanceSecretStorage.loadCipherData(InstanceSecretStorage.java:116)  
at com.atlassian.bamboo.crypto.instance.InstanceSecretStorage.getCipherData(InstanceSecretStorage.java:122)  
at com.atlassian.bamboo.crypto.instance.InstanceSecretStorage.getOrCreateCipherData(InstanceSecretStorage.java:101)  
at com.atlassian.bamboo.crypto.instance.InstanceSecretStorage.getCipherData(InstanceSecretStorage.java:94)  
at com.atlassian.bamboo.crypto.instance.InstanceSecretStorage.getKeyAndIv(InstanceSecretStorage.java:84)  
at com.atlassian.bamboo.crypto.instance.InstanceCipherProvider.initialiseCurrentCipher(InstanceCipherProvider.java:28)  
at com.atlassian.bamboo.crypto.instance.SecretEncryptionServiceInternalImpl.postConstruct(SecretEncryptionServiceInternalImpl.java:39)  
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at java.lang.reflect.Method.invoke(Method.java:498)  
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:365)  
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:308)  
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:135)  
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:422)  
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1698)  
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579)  
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)  
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)  
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)  
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)  
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)  
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)  
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)  
at org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver$1.getTarget(ContextAnnotationAutowireCandidateResolver.java:90)  
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:193)  
at com.sun.proxy.$Proxy219.isEncrypted(Unknown Source)  
at com.atlassian.bamboo.crypto.instance.SecretEncryptionServiceImpl.isEncrypted(SecretEncryptionServiceImpl.java:15)  
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at java.lang.reflect.Method.invoke(Method.java:498)  
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)  
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:206)  
at com.sun.proxy.$Proxy193.isEncrypted(Unknown Source)  
at com.atlassian.bamboo.security.MigratingEncryptionService.decrypt(MigratingEncryptionService.java:27)  
at com.atlassian.bamboo.upgrade.tasks.v5_15.UpgradeTask51505EncryptRepositoryDefinition.decryptValue(UpgradeTask51505EncryptRepositoryDefinition.java:165)  
at com.atlassian.bamboo.upgrade.tasks.v5_15.UpgradeTask51505EncryptRepositoryDefinition.updateRepository(UpgradeTask51505EncryptRepositoryDefinition.java:140)  
at com.atlassian.bamboo.upgrade.tasks.v5_15.UpgradeTask51505EncryptRepositoryDefinition.processRepository(UpgradeTask51505EncryptRepositoryDefinition.java:116)  
at com.atlassian.bamboo.upgrade.tasks.v5_15.UpgradeTask51505EncryptRepositoryDefinition.lambda$doUpgrade$0(UpgradeTask51505EncryptRepositoryDefinition.java:92)  
at org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:383)  
at org.springframework.orm.hibernate5.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:349)  
at com.atlassian.bamboo.persistence.BambooTransactionHibernateTemplate$1.doInTransaction(BambooTransactionHibernateTemplate.java:36)  
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)  
at com.atlassian.bamboo.persistence.BambooTransactionHibernateTemplate.execute(BambooTransactionHibernateTemplate.java:28)  
at com.atlassian.bamboo.persistence.BambooTransactionHibernateTemplate.execute(BambooTransactionHibernateTemplate.java:33)  
at com.atlassian.bamboo.upgrade.tasks.v5_15.UpgradeTask51505EncryptRepositoryDefinition.doUpgrade(UpgradeTask51505EncryptRepositoryDefinition.java:87)  
at com.atlassian.bamboo.upgrade.AbstractUpgradeManager.runUpgradeTask(AbstractUpgradeManager.java:186)  
at com.atlassian.bamboo.upgrade.UpgradeManagerImpl.doUpgrade(UpgradeManagerImpl.java:133)  
at com.atlassian.bamboo.upgrade.UpgradeLauncher.lambda$upgradeAndStartBamboo$0(UpgradeLauncher.java:104)  
at java.util.concurrent.FutureTask.run(FutureTask.java:266)  
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)  
at java.util.concurrent.FutureTask.run(FutureTask.java:266)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  
at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48)  
at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)  
at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)  
at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)  
at java.lang.Thread.run(Thread.java:748)


author: Joe Bednarz
body: End of log file shows:

2018-11-07 13:44:03,789 INFO \[17-UpgradeTaskBackgroundThread:pool-31-thread-1\] \[AbstractUpgradeManager\] Task 51505 completed successfully.  
2018-11-07 13:44:03,789 FATAL \[localhost-startStop-1\] \[UpgradeLauncher\] Upgrade task error: Task for build 51505 failed with exception: Unable to read cipher data for 0  
2018-11-07 13:44:03,805 INFO \[localhost-startStop-1\] \[CompressingFilter\] CompressingFilter has initialized  
2018-11-07 13:44:04,384 INFO \[localhost-startStop-1\] \[SpringObjectFactory\] Setting autowire strategy to name  
2018-11-07 13:44:04,384 INFO \[localhost-startStop-1\] \[StrutsSpringObjectFactory\] Struts-Spring integration initialised successfully  
2018-11-07 13:44:05,367 INFO \[localhost-startStop-1\] \[Dispatchers\] Dispatcher org.apache.struts2.dispatcher.Dispatcher initialised  
2018-11-07 13:44:05,430 INFO \[localhost-startStop-1\] \[SpringObjectFactory\] Setting autowire strategy to name  
2018-11-07 13:44:05,430 INFO \[localhost-startStop-1\] \[StrutsSpringObjectFactory\] Struts-Spring integration initialised successfully  
2018-11-07 13:44:06,664 INFO \[localhost-startStop-1\] \[AccessLogFilter\] AccessLogFilter initialized. Format is: \<user\> \<url\> \<starting memory free (kb)\> +- \<difference in free mem (kb)\> \<query time (ms)\>  
2018-11-07 13:44:06,711 INFO \[localhost-startStop-1\] \[SpringObjectFactory\] Setting autowire strategy to name  
2018-11-07 13:44:06,711 INFO \[localhost-startStop-1\] \[StrutsSpringObjectFactory\] Struts-Spring integration initialised successfully  
2018-11-07 13:44:06,867 INFO \[localhost-startStop-1\] \[Dispatchers\] Dispatcher org.apache.struts2.dispatcher.Dispatcher initialised  
2018-11-07 13:44:06,899 INFO \[localhost-startStop-1\] \[SpringObjectFactory\] Setting autowire strategy to name  
2018-11-07 13:44:06,899 INFO \[localhost-startStop-1\] \[StrutsSpringObjectFactory\] Struts-Spring integration initialised successfully  
2018-11-07 13:44:07,305 INFO \[http-apr-8085-exec-2\] \[JohnsonFilter\] The application is still starting up, or there are errors. Redirecting request from '/start.action' to '/error/errorEvents.action'  
2018-11-07 13:44:07,321 INFO \[http-apr-8085-exec-3\] \[AccessLogFilter\] 192.168.42.147 GET http://moore:8085/error/errorEvents.action 538511kb  
2018-11-07 13:44:08,149 INFO \[http-apr-8085-exec-5\] \[JohnsonFilter\] The application is still starting up, or there are errors. Redirecting request from '/s/en_US/60606/1/images/logos/aui-header-logo-bamboo.png' to '/error/errorEvents.action'  
2018-11-07 13:44:08,149 INFO \[http-apr-8085-exec-6\] \[AccessLogFilter\] 192.168.42.147 GET http://moore:8085/error/errorEvents.action 613168kb


author: Alexey Chystoprudov
body: It looks like upgrade to version 5.15 was failed.

I see my colleague [Kah Loun Foong](https://community.atlassian.com/t5/user/viewprofilepage/user-id/502088) already created support request on your behalf, let's continue discussion there.


author: Joe Bednarz
body: I ended up matching this environment to my production. I believe problem was that this environment was using C:\\Program Files\\ as the bamboo install and home. When I matched to production, which was using E:\\Bamboo, upgrade went with issue.

Thank you for your help!