Unsuccessful: create index Error in Logs Using MySQL
Symptoms
The following appears in the atlassian-bamboo.log
:
2013-08-13 22:58:19,471 ERROR [main] [SchemaUpdate] Unsuccessful: create index dep_ver_commit_rev_idx on DEPLOYMENT_VERSION_COMMIT (COMMIT_REVISION)
2013-08-13 22:58:19,471 ERROR [main] [SchemaUpdate] BLOB/TEXT column 'COMMIT_REVISION' used in key specification without a key length
Diagnosis
Check your <bamboo-home>/bamboo.cfg.xml
for the following line:
<property name="hibernate.dialect">com.atlassian.hibernate.dialect.MySQLDialect</property>
If it is present, Hibernate is using an outdated dialect for processing SQL statements.
Cause
A table in your Bamboo database is using text
for the column type, but the query to add the index is expecting varchar
. As of MySQL 5.0.3, larger varchars
can be specified, so Bamboo no longer creates many of these tables as text
(see this bug report for additional details). Per the diagnosis section, the dialect is causing Hibernate to create queries compatible with versions of MySQL prior to 5.0.3.
Resolution
- Shutdown Bamboo.
Edit your
<bamboo-home>/bamboo.cfg.xml
and change thehibernate.dialect
to match this line:<property name="hibernate.dialect">com.atlassian.hibernate.dialect.MySQL5Dialect</property>
- Change columns to
varchar
:
Create a database dump without data:
mysqldump --no-data -u <username> -p <password> bamboodb > bamboodb.sql
Search for columns using
text
in their CREATE TABLE statements. As of Bamboo 5.0, the only column that should be usingtext
is thePUBLIC_KEY_CLOB
column in theTRUSTED_APPS
table.
For Unix users, you can grep the information into an outfile in your working directory using:grep -B10 " text" /path/to/bamboo.sql | grep "CREATE TABLE\| text" |tee ./outfile
Modify all of your tables using this query format:
ALTER table DEPLOYMENT_VERSION_COMMIT MODIFY column COMMIT_REVISION varchar(4000) DEFAULT NULL;