Blocking message - Specified key was too long

Hello.

I’m pretty new to Cuba Platform.

I had my first project in half an hour up and running, connected to a mysql database.
I used studio 6.9.5 to do that.

I recently moved to a new workstation and installed the new studio 6.9.10. I tried to do a project from scratch like I did before. But during createdb I get this exception:

Execution failed for task ‘:app-core:createDb’.

Exception when executing SQL:
create unique index IDX_SEC_LOC_CNSTRNT_MSG_UNIQUE
on SEC_LOCALIZED_CONSTRAINT_MSG (ENTITY_NAME, OPERATION_TYPE, DELETE_TS_NN)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  • Get more help at https://help.gradle.org
    BUILD FAILED in 1s
    2 actionable tasks: 1 executed, 1 up-to-date
    [10:39:09.274] Task ‘createDb’ failed
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes

The weird thing is that even returning to 6.9.5 in the previous workstation has the same result, both with a new project and with the re-creation of the db of the previous project.

I tried mariadb on different machines (Ver 15.1 - Distribution 10.1.26-MariaDB). The mariadb on my machine for example was installed from scratch.

I tried different version of Cuba Studio, I tried both new and existing project. I tried different versions of mysql-connector-java.jar

From now on I constantly get this error, no matter what I change.

Maybe the latest mariadb update broke something?

UPDATE: I noticed that collation of table is Now is always a ‘utf8mb4_general_ci’.
I tried to change it in the url with parameters like ‘connectionCollation’, but the result is the same, and the collation does not change.

UPDATE 2: I found this difference between Debian MariaDb and other distros:
character_set_server: (Debian)utf8mb4 , (Others)latin1
collation_server: (Debian)utf8mb4_general_ci , (Others)latin1_swedish_ci

Hi,
I opened an issue: MySQL database creation error in case of using utf8mb4 encoding · Issue #1368 · cuba-platform/cuba · GitHub
It is related to the old one: https://youtrack.cuba-platform.com/issue/PL-8879
The issue happens only if your database has utf8mb4 character set.

As a workaround, to make studio create a database with a correct charset to you, you may specify a create database instruction. In the build.gradle file find the createDb task and add the createDbSql property there:

    task createDb(dependsOn: assembleDbScripts, description: 'Creates local database', type: CubaDbCreation) {
        connectionParams = '?useSSL=false&allowMultiQueries=true'
        dbms = 'mysql'
        host = 'localhost'
        dbName = 'mysqltest'
        dbUser = 'cuba'
        dbPassword = 'cuba'
        createDbSql = "CREATE DATABASE $dbName CHARACTER SET utf8 COLLATE utf8_general_ci"
    }
1 Like

Thanks @gorbunkov, utf8mb4 is the default for Debian distributions of MariaDb.

The workaround you mentioned is great and it is indeed a good solution to force all developers to have the same encoding in their machines.

Another workaround is to force mariadb in the configuration to have the same defaults as in other OS distributions.

But keep in mind that although MariaDB seems to work fine, it’s not officially supported.