Bamboo build result can't be saved
Asked by Kevin Maes:

We have a couple of build plans that run well untill the results are stored into the database.

We get the following error:

```
System Error DetailsBuild Swiftcom - swiftcom2 5.7 Release - Default Job 1 : Could not save the build results. Data could be in an inconsistent state. (org.springframework.jdbc.UncategorizedSQLException : Hibernate operation: Could not execute JDBC batch update; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1364]; Field 'LABEL' doesn't have a default value; nested exception is java.sql.BatchUpdateException: Field 'LABEL' doesn't have a default value)Occurred: 07 Aug 2014, 12:58:55 PM Agent: Local Agent 5________________________________________org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Could not execute JDBC batch update; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1364]; Field 'LABEL' doesn't have a default value; nested exception is java.sql.BatchUpdateException: Field 'LABEL' doesn't have a default valueCaused by: java.sql.BatchUpdateException: Field 'LABEL' doesn't have a default valueat com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2055)at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54)at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:128)at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2440)at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2394)at net.sf.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1823)at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3654)at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)at net.sf.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:385)at com.atlassian.bamboo.resultsummary.BuildResultsSummaryHibernateDao$32.doInHibernate(BuildResultsSummaryHibernateDao.java:1272)at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:370)at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337)at com.atlassian.bamboo.resultsummary.BuildResultsSummaryHibernateDao.findLastBuildResultBeforeWithTests(BuildResultsSummaryHibernateDao.java:1261)at com.atlassian.bamboo.resultsummary.BuildResultsSummaryManagerImpl.findLastBuildResultBeforeWithTests(BuildResultsSummaryManagerImpl.java:1322)at sun.reflect.GeneratedMethodAccessor1806.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:606)at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)at com.atlassian.bamboo.security.acegi.intercept.aopalliance.AuthorityOverrideMethodSecurityInterceptor.invoke(AuthorityOverrideMethodSecurityInterceptor.java:30)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)at com.sun.proxy.$Proxy44.findLastBuildResultBeforeWithTests(Unknown Source)at com.atlassian.bamboo.resultsummary.tests.TestsManagerImpl.getPreviousResultsSummary(TestsManagerImpl.java:722)at com.atlassian.bamboo.resultsummary.tests.TestsManagerImpl.copyTestResultsToBuildResultsSummary(TestsManagerImpl.java:348)at com.atlassian.bamboo.resultsummary.tests.TestsManagerImpl.copyTestResultsToBuildResultsSummary(TestsManagerImpl.java:319)at sun.reflect.GeneratedMethodAccessor1523.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:606)at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)at com.sun.proxy.$Proxy82.copyTestResultsToBuildResultsSummary(Unknown Source)at com.atlassian.bamboo.plan.PlanStatePersisterImpl.saveFinishedBuildResult(PlanStatePersisterImpl.java:109)at sun.reflect.GeneratedMethodAccessor1521.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:606)at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at com.atlassian.bamboo.author.AuthorCreatorServiceInterceptor.invoke(AuthorCreatorServiceInterceptor.java:46)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)at com.sun.proxy.$Proxy84.saveFinishedBuildResult(Unknown Source)at com.atlassian.bamboo.plan.PlanStatePersisterServiceImpl$1.call(PlanStatePersisterServiceImpl.java:42)at com.atlassian.bamboo.plan.PlanStatePersisterServiceImpl$1.call(PlanStatePersisterServiceImpl.java:38)at com.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:312)at com.atlassian.bamboo.plan.PlanStatePersisterServiceImpl.saveFinishedBuildResult(PlanStatePersisterServiceImpl.java:37)at com.atlassian.bamboo.v2.build.agent.LocalBuildResultProcessor.processBuildResult(LocalBuildResultProcessor.java:133)at com.atlassian.bamboo.v2.build.agent.LocalResultProcessorImpl.processResult(LocalResultProcessorImpl.java:38)at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.processResult(BuildAgentControllerImpl.java:179)at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:140)at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:110)at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:49)at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:31)at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:20)at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:52)at java.lang.Thread.run(Thread.java:745)Caused by: java.sql.SQLException: Field 'LABEL' doesn't have a default valueat com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2441)at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2007)... 67 more
```

So Field 'LABEL' doesn't have a default value. Seems to me we missed something in the latest upgrade. The weird thing is it doesn't happen for the other 20+ build plans that run fine.

We are on version 5.6.0 build 4409


Answers:
author: Edward Hooper
body: The table brs_artifact_link has a column LABEL that is NOT NULL and default NULL. I changed the it to a NULL'able column and \*that\* error message went away, but another one just like it was generated for a column called CHAIN_ARTIFACT in that same table. It is a bit(1) column that is NOT NULL and default NULL. I set the default to b'0' (binary 0) and it completes the task without error.

(There were changes to three two other tables, artifact and artifact_definition that also had a column LABEL that was NOT NULL and default NULL and they were changed but didn't negate the error message.)

I suspect there are a lot of these so tracking them down will be fun.

comments: author: Edward Hooper
body: ```
ALTER TABLE bamboo.brs_artifact_link MODIFY LABEL varchar(255) NULL;ALTER TABLE bamboo.brs_artifact_link MODIFY CHAIN_ARTIFACT bit(1) DEFAULT b'0';ALTER TABLE bamboo.artifact MODIFY LABEL varchar(255) NULL;ALTER TABLE bamboo.artifact_definition MODIFY LABEL varchar(255) NULL;
```


author: Kevin Maes
body: Thanks for your input.

Changing the database scheme is the obvious solution, but I was hopeing someone could point me out something we missed in the installation or is this a bug.


author: Edward Hooper
body: I believe this is a bug. We had an older version of Bamboo installed that had the columns set this way, but after an upgrade the configuration changed.


author: Kevin Maes
body: Now another issue in the same trend pops up

We will probably have to fix it the same way. Altering the database scheme

```
Caused by: java.sql.SQLException: Field 'CHAIN_ARTIFACT' doesn't have a default value	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2441)	at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2007)	... 67 more
```


author: Sander Verschuren
body: Hi, I'm investigating this problem together with Kevin.

No, we are not using the automated labels feature.


author: EddieW
body: Are you using the automated labels feature for those builds? Looks like the regexp is matching but not providing data.

<https://confluence.atlassian.com/display/BAMBOO/Configuring+automatic+labelling+of+job+build+results>