Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-21059

All VARIABLE_VALUE columns should use clob instead of varchar(4000)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Low Low
    • 7.2.0, 7.1.2
    • 7.1.1
    • Variables
    • None

      Issue Summary

      Some variable related tables still use varchar(4000) while they should use CLOB.

      Steps to Reproduce

      1. Have a version of Bamboo installed, prior to 7.1.1, where it is possible to upgrade to 7.1.1.
      2. Create a password variable with a long value (close to the 4000 char limit).
      3. Upgrade Bamboo to version 7.1.1.

      Expected Results

      Bamboo upgrades with no errors.

      Actual Results

      The upgrade process fails. In the logs we can see: 

      2020-08-27 11:58:22,955 INFO [18-UpgradeTaskBackgroundThread:pool-40-thread-1] [AbstractUpgradeManager] ---------------------------------------------------------------
      2020-08-27 11:58:22,955 INFO [18-UpgradeTaskBackgroundThread:pool-40-thread-1] [AbstractUpgradeManager] 70102 : Encrypt data in VARIABLE_CONTEXT table (post-bootstrap)
      2020-08-27 11:58:22,955 INFO [18-UpgradeTaskBackgroundThread:pool-40-thread-1] [AbstractUpgradeManager] ---------------------------------------------------------------
      (...)
      2020-08-27 11:58:23,893 INFO [18-UpgradeTaskBackgroundThread:pool-40-thread-1] [AbstractVariableDataEncryptionTask] Variable 'variable_name' has value length 3096 and encrypted value length 4152 is more than db column size - 4000 characters. Please decrease its size
      2020-08-27 11:58:23,897 WARN [18-UpgradeTaskBackgroundThread:pool-40-thread-1] [SqlExceptionHelper] SQL Error: 0, SQLState: 22001
      2020-08-27 11:58:23,898 ERROR [18-UpgradeTaskBackgroundThread:pool-40-thread-1] [SqlExceptionHelper] ERROR: value too long for type character varying(4000)
      2020-08-27 11:58:23,902 ERROR [18-UpgradeTaskBackgroundThread:pool-40-thread-1] [AbstractUpgradeManager] org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement
      org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement
      	at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:251)
      	at org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:387)
      	at org.springframework.orm.hibernate5.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:350)
      	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.AbstractVariableDataEncryptionTask.updateVariableValuesByValue(AbstractVariableDataEncryptionTask.java:133)
      (...)	
      Caused by: org.hibernate.exception.DataException: could not execute statement
      	at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:118)
      	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
      	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
      	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
      	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178)
      	at org.hibernate.engine.query.spi.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:107)
      	at org.hibernate.internal.SessionImpl.executeNativeUpdate(SessionImpl.java:1593)
      	at org.hibernate.query.internal.NativeQueryImpl.doExecuteUpdate(NativeQueryImpl.java:292)
      	at org.hibernate.query.internal.AbstractProducedQuery.executeUpdate(AbstractProducedQuery.java:1594)
      	at com.atlassian.bamboo.upgrade.tasks.AbstractVariableDataEncryptionTask.encryptVariableValue(AbstractVariableDataEncryptionTask.java:176)
      (...)
      Caused by: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(4000)
      
      (...)
      
      

      Workaround

      For versions prior 7.1.1: Currently there is no known workaround for this behavior. A workaround will be added here when available

      For version 7.1.1: atlassian-bamboo-web-7.1.1-varsizepatch.jar

      1. Stop Bamboo.
      2. Download the file:
      3. Run the following queries:
        ALTER TABLE VARIABLE_CONTEXT ALTER COLUMN VARIABLE_VALUE TYPE text;
        ALTER TABLE VARIABLE_BASELINE_ITEM ALTER COLUMN VARIABLE_VALUE TYPE text;
        ALTER TABLE VARIABLE_SUBSTITUTION ALTER COLUMN VARIABLE_VALUE TYPE text;
        ALTER TABLE STAGE_VARIABLE_CONTEXT ALTER COLUMN VARIABLE_VALUE TYPE text;
        
      1. Navigate to the folder <bamboo_server_directory>/atlassian-bamboo/WEB-INF/lib/. You will find a file called atlassian-bamboo-web-7.1.1.jar. Back it up.
      2. Place the new jar in that folder, and change its name to atlassian-bamboo-web-7.1.1.jar, to make it look like the previous one.
      3. Start Bamboo again.

              mgardias Marcin Gardias
              mgardias Marcin Gardias
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: