Upgrade to 14.0.1 failed - stuck now

Nextcloud version: 14.0.0.19
Operating system and version: Ubuntu 18.04.1
Apache version: 2.4.29
PHP version: 7.2

The issue you are facing:
Followed the notice that 14.0.1 was available and applied the upgrade via the web updater. The update ended with an error and I cannot get the server running again.
Tried to reinstall 14.0.0, but that generated the same error, while the server was running fine before. Even restored the backup from last night, but that did not help either.
With reference to the error (see below): 4-Byte support for MySQL was enabled since April of this year and gave no problems earlier.

Is this the first time youā€™ve seen this error?: Yes

Steps to replicate it: sudo -u www-data php occ upgrade

The output of your Nextcloud log in:

Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'ALTER TABLE oc_authtoken ADD private_key LONGTEXT DEFAULT NULL, ADD public_key LONGTEXT DEFAULT NULL, ADD version SMALLINT UNSIGNED DEFAULT 1 NOT NULL':
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
Update failed

The output of your config.php file in /path/to/nextcloud:

<?php
$CONFIG = array (
  'instanceid' => 'xxxxxxxxxxxx',
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxx',
  'trusted_domains' => 
  array (
    0 => 'cloud-server',
    1 => '192.168.1.4',
    2 => 'xxxxxxxx',
    3 => 'xxxxxxxxx',
  ),
  'datadirectory' => '/var/lib/nextcloud/data',
  'overwrite.cli.url' => 'https://xxxxxxxxx',
  'htaccess.RewriteBase' => '/',
  'dbtype' => 'mysql',
  'mysql.utf8mb4' => true,
  'version' => '13.0.6.1',
  'dbname' => 'ocdb',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'xxxx',
  'dbpassword' => 'xxxxxx',
  'theme' => '',
  'trashbin_retention_obligation' => 'auto, 30',
  'versions_retention_obligation' => 'auto',
  'mail_smtpmode' => 'smtp',
  'mail_from_address' => 'xxxxx',
  'mail_domain' => 'xxxxxl',
  'mail_smtphost' => 'xxxxxx',
  'mail_smtpport' => '587',
  'mail_smtpsecure' => 'tls',
  'mail_smtpauth' => 1,
  'mail_smtpauthtype' => 'PLAIN',
  'mail_smtpname' => 'xxxxxxx',
  'mail_smtppassword' => 'xxxxxxx',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => 6379,
  ),
  'installed' => true,
  'loglevel' => 2,
  'updatechecker' => true,
  'updater.release.channel' => 'stable',
  'maintenance' => true,
);

The output of your Apache log: Since server is not running, no relevant log messages appear.

Following the discussion over at https://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes#16820166 it looks like a VARCHAR(256) field used as a unique index with the UTF8mb4 character set isnā€™t supported. It would work with UTF8 though.

I disabled the MySQL 4-Byte support and everything is hunkey-dorey again. I had that configured as detailed in the Admin Manual under Database Configuration. The News app complained about it earlier.
It is strange that the problem arose after the upgrade. Ought not to happen according to me.
Anyway, thanks for pointing in the right direction Jurgen!

Did you upgrade/migrate your existing database tables to 4byte after enabling it in MySQL settings and Nextcloud config.php? Maybe non-4byte tables were attempted to be upgraded in 4byte way or such :thinking:.

4-Byte support was enabled since April of this year and gave no problems earlier; anything ran fine. The upgrade just broke it.

I donā€™t mean enabling support, but altering/migrating the existing database tables. I am really no expert in this, just have the idea it might lead to issues if Nextcloud wantā€™s to write a 4byte character to a table, that was not yet altered to utf8mb4, even that the database already supports it.
Perhaps worth to checkā€¦

https://docs.nextcloud.com/server/14/admin_manual/configuration_database/mysql_4byte_support.html#enabling-mysql-4-byte-support

  • Step 4, within mysql console: ALTER DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
  • Step 6, converting tables Nextcloud side: sudo -u www-data php /path/to/nextcloud/occ maintenance:repair

Did you do this as well in April?

Yes, followed all instructions from the admin manual that you stipulated. By the way; good to know that I use MariaDB.

Checked it again today and detected quite some tables of type ā€˜Antelopeā€™ instead of ā€˜Barracudaā€™. Changed them using SQL statements like ā€œALTER TABLE ocdb.oc_calendars ROW_FORMAT=DYNAMIC;ā€.
Concluded with the repair action, which gave anew the error messages I got earlier:

An exception occurred while executing ā€˜ALTER TABLE oc_authtoken CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;ā€™:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytesā€™ā€˜ā€™

Changed all settings back (removed barracuda settings from mysql config, disabling mysql.utf8mb4 in nextcloud config) and did a repair. That still left me with the error messages, but after disabling maintenance mode, the service ran happy again. Quite some tables were back to ā€˜Antelopeā€™ format however.

I will leave it as it is now.