New uuid format

With the bug fix MDEV-29959 →, MariaDB introduced a new internal storage format for the uuid data type. Tables created before keep the old format. If a Relution update changes such a table, the database migration fails with error 1833 and Relution does not start.

This guide applies only to installations using MariaDB. PostgreSQL is not affected.


Symptoms

On startup after an update, the Liquibase migration aborts, e.g. during the update to Relution 27.0.5 in the changeset db/2026/202610281200_relution_REL-14550.xml::20261028-001, which adds two columns to the table mdm_dvc. The Relution log contains a message like the following:

ERROR 1833: Cannot change column 'uuid': used in a foreign key constraint 'fk__mdm_apple_dvc_edu_config__mdm_dvc'

Table and foreign key may differ depending on the update. The location of the log files is described under Relution Logs →.


Cause

Which format a table uses depends on the MariaDB version that last wrote its table definition (file <table>.frm in the data directory). The new format applies from the following versions:

Release seriesNew format from
10.910.9.8
10.1010.10.6
10.1110.11.5
11.011.0.3
11.111.1.2
11.2 and newer11.2.1

Tables created or last rebuilt under an older version keep using the old format. In SHOW CREATE TABLE, both formats look the same (uuid). Such a mixed state results from every MariaDB update across the versions listed above; in Docker installations, pulling a newer image of the same release series (e.g. mariadb:10.11) is already enough.

On an ALTER TABLE, MariaDB internally converts the table’s uuid columns to the new format and treats this as a change of the column. If foreign keys depend on this column, MariaDB rejects the change with error 1833. As a result, even just adding a new column fails.

Removing the foreign keys one by one beforehand does not help: DROP FOREIGN KEY is an ALTER TABLE as well and fails with the same error. The only remedy is to recreate all tables under the current MariaDB version.


Identify affected tables

The MariaDB version that last wrote a table is stored as a 4-byte value at position 51 of its .frm file. The following commands read this value for all tables of the Relution database and output the format (new or OLD), version and table name for each table. They do not change the database and can be run during operation.

The commands assume the database name relution. If a different database name was chosen during installation, it is replaced in the path.

Docker

The placeholders in angle brackets are replaced with the values from the Compose file (compose.yaml, docker-compose.yml in older installations). The data directory inside the MariaDB container is /var/lib/mysql.

docker exec <containername> sh -c 'cd /var/lib/mysql/relution && for f in *.frm; do echo "${f%.frm} $(od -An -t u4 -j 51 -N 4 "$f")"; done' | awk '
{
  v = $2
  new = (v == 0) ||
        (v >= 100908 && v < 100999) || (v >= 101006 && v < 101099) ||
        (v >= 101105 && v < 101199) || (v >= 110003 && v < 110099) ||
        (v >= 110102 && v < 110199) || (v >= 110201)
  printf "%-4s %-9s %s\n", (new ? "new" : "OLD"), int(v / 10000) "." int(v % 10000 / 100) "." (v % 100), $1
}' | sort

Linux (native)

The data directory is /var/lib/mysql by default. Different paths are set in the MariaDB configuration under datadir.

sudo sh -c 'cd /var/lib/mysql/relution && for f in *.frm; do echo "${f%.frm} $(od -An -t u4 -j 51 -N 4 "$f")"; done' | awk '
{
  v = $2
  new = (v == 0) ||
        (v >= 100908 && v < 100999) || (v >= 101006 && v < 101099) ||
        (v >= 101105 && v < 101199) || (v >= 110003 && v < 110099) ||
        (v >= 110102 && v < 110199) || (v >= 110201)
  printf "%-4s %-9s %s\n", (new ? "new" : "OLD"), int(v / 10000) "." int(v % 10000 / 100) "." (v % 100), $1
}' | sort

Windows

On Windows, the check is run in PowerShell. The path to the data directory is adjusted to the installation; it is set in my.ini under datadir.

Get-ChildItem -Path 'C:\Program Files\MariaDB 10.11\data\relution' -Filter *.frm | ForEach-Object {
    $fs = [System.IO.File]::Open($_.FullName, 'Open', 'Read', 'ReadWrite')
    try {
        $buf = New-Object byte[] 4
        $fs.Position = 51
        [void]$fs.Read($buf, 0, 4)
    } finally { $fs.Dispose() }
    $v = [BitConverter]::ToUInt32($buf, 0)
    $newUuid = ($v -eq 0) -or
               ($v -ge 100908 -and $v -lt 100999) -or
               ($v -ge 101006 -and $v -lt 101099) -or
               ($v -ge 101105 -and $v -lt 101199) -or
               ($v -ge 110003 -and $v -lt 110099) -or
               ($v -ge 110102 -and $v -lt 110199) -or
               ($v -ge 110201)
    [PSCustomObject]@{
        Table      = $_.BaseName
        FrmVersion = '{0}.{1}.{2}' -f [math]::Floor($v / 10000), [math]::Floor(($v % 10000) / 100), ($v % 100)
        UuidFormat = if ($newUuid) { 'new' } else { 'OLD' }
    }
} | Sort-Object UuidFormat, FrmVersion, Table | Format-Table -AutoSize

Evaluate the result

If the output lists tables with OLD while the MariaDB server already runs one of the versions listed above or newer, the database is affected. A shortened example:

new  12.3.2    …
OLD  10.11.4   mdm_apple_dvc_edu_config
OLD  10.11.4   mdm_dvc

The version of the running server is shown by SELECT VERSION(); in the MariaDB console. If only tables with new are listed, the error has a different cause.


Solution

The database is backed up with a dump, deleted, recreated and restored from the dump. In the process, the current MariaDB server recreates all tables, so that afterwards they consistently use the new uuid format. The data itself remains unchanged.

In the course of this procedure, the Relution database is deleted. Before deleting it, it is mandatory to verify that the dump is complete.

Required steps:

  1. The Relution service is stopped.
  2. A complete dump of the relution database is created with mariadb-dump, see also Disaster Recovery →.
  3. The dump is checked. The last line of the file reads -- Dump completed on …. If it is missing, the dump is incomplete and the procedure is not continued.
  4. The database is deleted and recreated with the character set utf8mb4 and the collation utf8mb4_general_ci.
  5. The dump is imported into the new database.
  6. The check from Identify affected tables is repeated. All tables are now listed as new.
  7. The Relution service is started. The aborted database migration runs again.

The placeholders in angle brackets in the following commands are replaced with the values from application.yml or the Compose file. The Relution database user needs the privilege to drop and create the database; this is the case in a standard installation. Otherwise, the user root is used for step 4. For large databases, steps 2 and 5 can take some time.

Docker

The commands are run in the directory /opt/relution/.

docker compose stop relution

docker exec <containername> mariadb-dump -u <username> -p<password> --single-transaction relution > relution_backup.sql

tail -n 1 relution_backup.sql

docker exec <containername> mariadb -u <username> -p<password> -e "DROP DATABASE relution; CREATE DATABASE relution CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"

docker exec -i <containername> mariadb -u <username> -p<password> relution < relution_backup.sql

docker compose start relution

The password is specified directly after -p here, because the dump is imported via standard input and an interactive password prompt is not possible.

To avoid the password being stored in plain text in the shell history, the command can be prefixed with a space, or the history can be cleaned up afterwards.

Linux (native)

sudo systemctl stop relution

mariadb-dump -u <username> -p --single-transaction relution > relution_backup.sql

tail -n 1 relution_backup.sql

mariadb -u <username> -p -e "DROP DATABASE relution; CREATE DATABASE relution CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"

mariadb -u <username> -p relution < relution_backup.sql

sudo systemctl start relution

Windows

On Windows, the same mariadb-dump and mariadb calls are run in the command prompt, e.g. via the shortcut Command Prompt (MariaDB 10.11 (x64)). In PowerShell, redirection with < does not work. There, the last line of the dump is displayed with Get-Content relution_backup.sql -Tail 1. The Relution service is stopped and started via the Windows service management.


Verify the result

If Relution starts after the restore and the database migration completes without errors, the conversion is finished. Since the dump restores the original collation of each table, a check as described in Fix MariaDB collation → is recommended afterwards.

How helpful was this article?