SAKAI_CONFIG_ITEM hibernate creation fails with utf8mb4 db

Description

SAKAI_CONFIG_ITEM added in KNL-1063 is confusingly created twice, once by Hibernate:

kernel/api/src/main/java/org/sakaiproject/config/api/HibernateConfigItem.hbm.xml

and once with SQL ddl:

kernel/kernel-impl/src/main/sql/mysql/sakai_config_item.sql

On mysql databases with default character set utf8mb4, the Hibernate creations (which seems to run first) fails:

java.sql.SQLSyntaxErrorException: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs

The SQL attempted is:

create table SAKAI_CONFIG_ITEM
(ID bigint not null auto_increment,
NODE varchar(255),
NAME varchar(255) not null,
VALUE varchar(4000),
RAW_VALUE varchar(4000),
TYPE varchar(255) not null,
DEFAULT_VALUE varchar(4000),
DESCRIPTION varchar(4000),
SOURCE varchar(255),
DEFAULTED bit not null,
REGISTERED bit not null,
SECURED bit not null,
DYNAMIC bit not null,
CREATED datetime not null,
MODIFIED datetime not null,
POLL_ON datetime,
primary key (ID)) ENGINE=InnoDB;

To fix this, it looks like the hbm.xml should be adjusted, although it seems there are some complications around this which the DDL SQL was presumably intended to avoid. It's sufficient to reduce the length of 4000 for these 4 fields to something a little smaller, e.g. 3500.

Although in the Sakai 11 conversion script, these are defined as LONGTEXT.

Activity

Show:

Stephen Marquard November 14, 2016 at 11:41 AM

No, it's related to utf8mb4. With 4-byte UTF8, the max row length would be 4000*4*4 = 64K plus a couple of other fields that push the total row length over 65535. With 3-byte UTF8, max row length is 4000*4*3 = 48K so not close to the limit.

Matthew Jones November 14, 2016 at 11:38 AM

Is this more of an issue with innodb_large_prefix (default in 5.7.7) rather than utf8mb4?

Fixed

Details

Priority

Affects versions

Fix versions

Components

Assignee

Reporter

Created November 11, 2016 at 8:40 AM
Updated April 25, 2018 at 3:18 PM
Resolved January 12, 2017 at 10:13 AM