Issue Details (XML | Word | Printable)

Key: CONF-2783
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Daniel Ostermeier
Reporter: Dave Loeng [Atlassian]
Votes: 0
Watchers: 0
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Confluence

MySQL error in setup: Specified key was too long

Created: 20/Feb/05 11:08 PM   Updated: 11/Jun/08 09:11 PM
Component/s: Setup / Installation
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Issue Links:
Duplicate
 
Reference
 

Participants: Daniel Ostermeier, Dave Loeng [Atlassian] and Roy Hartono
Since last comment: 24 weeks, 5 days ago
Resolution Date: 04/Apr/05 07:45 PM
Labels:


 Description  « Hide
Due to an apparent bug in MySQL: http://bugs.mysql.com/bug.php?id=4541, one of Confluence's tables: os_propertyentry, cannot be created when "Confluence+MySQL is configured for foreign character sets or UTF-8": failing with the following error:

create table OS_PROPERTYENTRY (entity_name VARCHAR(125) not null, entity_id BIGINT not null, entity_
key VARCHAR(255) not null, key_type INTEGER, boolean_val BIT, double_val DOUBLE PRECISION, string_va
l VARCHAR(255), long_val BIGINT, int_val INTEGER, date_val DATETIME, primary key (entity_name, entit
y_id, entity_key))
Nov 10, 2004 7:58:30 PM net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Unsuccessful: create table OS_PROPERTYENTRY (entity_name VARCHAR(125) not null, entity_id BI
GINT not null, entity_key VARCHAR(255) not null, key_type INTEGER, boolean_val BIT, double_val DOUBL
E PRECISION, string_val VARCHAR(255), long_val BIGINT, int_val INTEGER, date_val DATETIME, primary k
ey (entity_name, entity_id, entity_key))
Nov 10, 2004 7:58:30 PM net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Syntax error or access violation message from server: "Specified key was too long; max key l
ength is 1024 bytes"

or in summary:

"Specified key was too long; max key length is 1024 bytes"

Because a UTF-8 character is stored as three bytes in MySQL the maximum key length can only be 1024/3 characters long. The compound key in the os_propertyentry table seems to be violating this constraint.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Dave Loeng [Atlassian] added a comment - 20/Feb/05 11:12 PM
There is no proper workaround for this bug.

Until we find a solution your options are:

1) Disable UTF-8 support in the database
2) Use a different database

However this does not seem to consistently happen for all our MySQL customers. In fact, we are able to setup Confluence against a UTF-8 MySQL database (version 4.0.20) with no problems.


Daniel Ostermeier added a comment - 23/May/05 07:33 PM
I just installed mysql 4.1.11-nt, using UTF-8 support by default and have encountered the problem.

From charles investigation, the problem is as follows:
1) we are creating a composite key, with varchar(125), varchar(255) and bigint.
2) mysql has a max key size of 1024 bytes.
3) the default database encoding is UTF-8.
4) mysql attempts to allocate 3 bytes for each character since UTF-8 can be up to 3 bytes per char.
5) 125 * (3 bytes) + 255 * (3 bytes) + 1 * (8 bytes) = 1148 bytes.

Options:
1) change character encoding for the varchar columns, supported by mysql 4.1.x
2) reduce the size of the varchar columns to bring them below 1024 bytes.


Daniel Ostermeier added a comment - 24/May/05 06:52 PM
This task will fix CONF-2783

Daniel Ostermeier added a comment - 24/May/05 07:56 PM
have updated the .hbm.xml file to limit the key length to an allowable size.

Roy Hartono added a comment - 11/Jun/08 09:10 PM - edited
If you are unable to import the data dump to your database, switching to latin1 might help.

IE. comment out the default-character-set=utf8 line in your my.ini file (windows) or my.cnf

# default-character-set=utf8