[Solved]NC16.0.1 : Enabling MySQL 4-byte

Nextcloud version : 16.0.1
Operating system and version : Ubunutu 18.04 LTS (up-to-date)
Apache : Apache/2.4.29 (Ubuntu)
PHP version : 7.2
MySQL : 5.7.26

Issue :
Enabling MySQL 4-byte fails while “repairing” table ‘oc_filecache’.

Is this the first time you’ve seen this error? : This always do the same on the same configuration. (VM rolledback from last stable snapshot).

Steps to replicate it:

  1. Following the " Enabling MySQL 4-byte" instruction for MySQL (older than 8.0)
  2. While doing the repair maintenance, all tables before ‘oc_filecache’ are converted to utf8mb4_bin
  3. The oc_filecache table fails to be converted and is dropped

The output of ‘sudo -u www-data php occ -vvv maintenance:repair’:

  • Change row format for oc_file_locks …
  • Change collation for oc_file_locks …
  • Change row format for oc_filecache …

In AbstractMySQLDriver.php line 125:

[Doctrine\DBAL\Exception\DriverException]
An exception occurred while executing ‘ALTER TABLE oc_filecache ROW_FORMAT = DYNAMIC;’:

SQLSTATE[HY000]: General error: 1712 Index PRIMARY is corrupted

Exception trace:
() at /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:125
Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException() at /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:184
Doctrine\DBAL\DBALException::wrapException() at /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:158
Doctrine\DBAL\DBALException::driverExceptionDuringQuery() at /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Statement.php:178
Doctrine\DBAL\Statement->execute() at /var/www/html/nextcloud/lib/private/Repair/Collation.php:83
OC\Repair\Collation->run() at /var/www/html/nextcloud/lib/private/Repair.php:100
OC\Repair->run() at /var/www/html/nextcloud/core/Command/Maintenance/Repair.php:123
OC\Core\Command\Maintenance\Repair->execute() at /var/www/html/nextcloud/3rdparty/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /var/www/html/nextcloud/3rdparty/symfony/console/Application.php:901
Symfony\Component\Console\Application->doRunCommand() at /var/www/html/nextcloud/3rdparty/symfony/console/Application.php:262
Symfony\Component\Console\Application->doRun() at /var/www/html/nextcloud/3rdparty/symfony/console/Application.php:145
Symfony\Component\Console\Application->run() at /var/www/html/nextcloud/lib/private/Console/Application.php:213
OC\Console\Application->run() at /var/www/html/nextcloud/console.php:97
require_once() at /var/www/html/nextcloud/occ:11

In PDOStatement.php line 143:

[Doctrine\DBAL\Driver\PDOException (HY000)]
SQLSTATE[HY000]: General error: 1712 Index PRIMARY is corrupted

Exception trace:
() at /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:143
Doctrine\DBAL\Driver\PDOStatement->execute() at /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Statement.php:169
Doctrine\DBAL\Statement->execute() at /var/www/html/nextcloud/lib/private/Repair/Collation.php:83
OC\Repair\Collation->run() at /var/www/html/nextcloud/lib/private/Repair.php:100
OC\Repair->run() at /var/www/html/nextcloud/core/Command/Maintenance/Repair.php:123
OC\Core\Command\Maintenance\Repair->execute() at /var/www/html/nextcloud/3rdparty/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /var/www/html/nextcloud/3rdparty/symfony/console/Application.php:901
Symfony\Component\Console\Application->doRunCommand() at /var/www/html/nextcloud/3rdparty/symfony/console/Application.php:262
Symfony\Component\Console\Application->doRun() at /var/www/html/nextcloud/3rdparty/symfony/console/Application.php:145
Symfony\Component\Console\Application->run() at /var/www/html/nextcloud/lib/private/Console/Application.php:213
OC\Console\Application->run() at /var/www/html/nextcloud/console.php:97
require_once() at /var/www/html/nextcloud/occ:11

In PDOStatement.php line 141:

[PDOException (HY000)]
SQLSTATE[HY000]: General error: 1712 Index PRIMARY is corrupted

Exception trace:
() at /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:141
PDOStatement->execute() at /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:141
Doctrine\DBAL\Driver\PDOStatement->execute() at /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Statement.php:169
Doctrine\DBAL\Statement->execute() at /var/www/html/nextcloud/lib/private/Repair/Collation.php:83
OC\Repair\Collation->run() at /var/www/html/nextcloud/lib/private/Repair.php:100
OC\Repair->run() at /var/www/html/nextcloud/core/Command/Maintenance/Repair.php:123
OC\Core\Command\Maintenance\Repair->execute() at /var/www/html/nextcloud/3rdparty/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /var/www/html/nextcloud/3rdparty/symfony/console/Application.php:901
Symfony\Component\Console\Application->doRunCommand() at /var/www/html/nextcloud/3rdparty/symfony/console/Application.php:262
Symfony\Component\Console\Application->doRun() at /var/www/html/nextcloud/3rdparty/symfony/console/Application.php:145
Symfony\Component\Console\Application->run() at /var/www/html/nextcloud/lib/private/Console/Application.php:213
OC\Console\Application->run() at /var/www/html/nextcloud/console.php:97
require_once() at /var/www/html/nextcloud/occ:11

The output of your config.php file in /path/to/nextcloud:
<?php
$CONFIG = array (
‘instanceid’ => ‘xxx’,
‘passwordsalt’ => ‘xxx’,
‘secret’ => ‘xxx’,
‘trusted_domains’ =>
array (
0 => ‘192.168.5.21’,
),
‘datadirectory’ => ‘/media/host_data’,
‘overwrite.cli.url’ => ‘http://192.168.5.21/nextcloud’,
‘dbtype’ => ‘mysql’,
‘version’ => ‘16.0.1.1’,
‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘localhost’,
‘dbport’ => ‘’,
‘dbtableprefix’ => ‘oc_’,
‘dbuser’ => ‘xxx’,
‘dbpassword’ => ‘xxx’,
‘logtimezone’ => ‘UTC’,
‘installed’ => true,
‘mail_from_address’ => ‘cr’,
‘mail_smtpmode’ => ‘smtp’,
‘mail_domain’ => ‘xxx.xxx’,
‘enable_previews’ => true,
‘preview_max_x’ => 2048,
‘preview_max_y’ => 2048,
‘preview_max_scale_factor’ => 10,
‘preview_max_filesize_image’ => 50,
‘preview_libreoffice_path’ => ‘/usr/bin/libreoffice’,
‘preview_office_cl_parameters’ => ’ --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir ',
‘mail_smtpsecure’ => ‘ssl’,
‘mail_smtpauthtype’ => ‘LOGIN’,
‘mail_smtphost’ => ‘xxx.xxx.xxx’,
‘mail_smtpport’ => ‘465’,
‘mail_smtpauth’ => 1,
‘mail_smtpname’ => ‘xxx@xxx.xxx’,
‘mail_smtppassword’ => ‘xxx’,
‘loglevel’ => 0,
‘log_type’ => ‘syslog’,
‘logfile’ => ‘’,
‘appstore.experimental.enabled’ => false,
‘maintenance’ => true,
‘theme’ => ‘’,
‘has_internet_connection’ => true,
‘updater.release.channel’ => ‘stable’,
‘memcache.local’ => ‘\OC\Memcache\Redis’,
‘filelocking.enabled’ => ‘true’,
‘memcache.distributed’ => ‘\OC\Memcache\Redis’,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘redis’ =>
array (
‘host’ => ‘localhost’,
‘port’ => 6379,
‘timeout’ => 0,
‘dbindex’ => 0,
),
‘updater.secret’ => ‘xxx’,
‘mysql.utf8mb4’ => true,
);

I searched for the same issue, but unsuccessfully. If you have any idea?
I can do tests on theVM thanks to snapshots :slight_smile:
Thanks by advance.

Have you tried to reset (cleanup) the file cache before doing the repair step?

See here:
https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html#file-operations

Thanks for your answer.

I juste tryed the files:cleanup and versions:cleanup (in case of :p) but I got the same behavior after.

I am back with the “solution”, or a turn around. if this could help others that got the same trouble…

I did all steps for Enabling MySQL 4-byte support and before starting the “repair” process, I used phpmyadmin to do the convertion of the table and of all concerned columns of the table.

After, I started the repair process that finally ended succesfully.