Docker: Update to 22 from 21 fails

Nextcloud version 22.0.11
Docker image tag 22

The issue you are facing:

Currently running NextCloud 21.0.0 which is running fine. When I try and upgrade by pulling the new container I get the error -

Update to 22.0.0

Exception: Database error when running migration latest for app core

Detailed logs

Preparing update

Set log level to debug

Turned on maintenance mode

Repair step: Repair MySQL collation

Repair info: All tables already have the correct collation → nothing to do

Repair step: Repair SQLite autoincrement

Repair step: Copy data from accounts table when migrating from ownCloud

Repair step: Drop account terms table when migrating from ownCloud

Updating database schema

Exception: Database error when running migration latest for app core

Is this the first time you’ve seen this error? (Y/N): Yes

Steps to replicate it:

  1. docker-compose up -d nextcloud
  2. Run upgrade from Web and it fails or running sudo -u www-data php occ upgrade on the container console.

The output of your Nextcloud log in Admin > Logging: tail of nextcloud.log

{"reqId":"0QIylBeBODN18b9la1jz","level":1,"time":"2021-07-13T06:52:11+00:00","remoteAddr":"ipaddress","user":"--","app":"no app in context","method":"GET","url":"/core/ajax/update.php?requesttoken=YBP8K1y1V5dStQQqgs9JhmdaREueHlqEbZHjr9wcePY%3D%3AIlSLWDfNOrgG5XdIxJUjsFQMFDvZbSn9HuaywqRoO7s%3D","message":"Deprecated event type for \\OC\\Repair::step: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67","version":"21.0.0.18"}
{"reqId":"0QIylBeBODN18b9la1jz","level":1,"time":"2021-07-13T06:52:11+00:00","remoteAddr":"ipaddress","user":"--","app":"updater","method":"GET","url":"/core/ajax/update.php?requesttoken=YBP8K1y1V5dStQQqgs9JhmdaREueHlqEbZHjr9wcePY%3D%3AIlSLWDfNOrgG5XdIxJUjsFQMFDvZbSn9HuaywqRoO7s%3D","message":"\\OC\\Repair::step: Repair step: Copy data from accounts table when migrating from ownCloud","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67","version":"21.0.0.18"}
{"reqId":"0QIylBeBODN18b9la1jz","level":1,"time":"2021-07-13T06:52:11+00:00","remoteAddr":"ipaddress","user":"--","app":"no app in context","method":"GET","url":"/core/ajax/update.php?requesttoken=YBP8K1y1V5dStQQqgs9JhmdaREueHlqEbZHjr9wcePY%3D%3AIlSLWDfNOrgG5XdIxJUjsFQMFDvZbSn9HuaywqRoO7s%3D","message":"Deprecated event type for \\OC\\Repair::step: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67","version":"21.0.0.18"}
{"reqId":"0QIylBeBODN18b9la1jz","level":1,"time":"2021-07-13T06:52:11+00:00","remoteAddr":"ipaddress","user":"--","app":"updater","method":"GET","url":"/core/ajax/update.php?requesttoken=YBP8K1y1V5dStQQqgs9JhmdaREueHlqEbZHjr9wcePY%3D%3AIlSLWDfNOrgG5XdIxJUjsFQMFDvZbSn9HuaywqRoO7s%3D","message":"\\OC\\Repair::step: Repair step: Drop account terms table when migrating from ownCloud","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67","version":"21.0.0.18"}
{"reqId":"0QIylBeBODN18b9la1jz","level":1,"time":"2021-07-13T06:52:11+00:00","remoteAddr":"ipaddress","user":"--","app":"updater","method":"GET","url":"/core/ajax/update.php?requesttoken=YBP8K1y1V5dStQQqgs9JhmdaREueHlqEbZHjr9wcePY%3D%3AIlSLWDfNOrgG5XdIxJUjsFQMFDvZbSn9HuaywqRoO7s%3D","message":"\\OC\\Updater::dbUpgradeBefore: Updating database schema","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67","version":"21.0.0.18"}
{"reqId":"0QIylBeBODN18b9la1jz","level":3,"time":"2021-07-13T06:52:12+00:00","remoteAddr":"ipaddress","user":"--","app":"no app in context","method":"GET","url":"/core/ajax/update.php?requesttoken=YBP8K1y1V5dStQQqgs9JhmdaREueHlqEbZHjr9wcePY%3D%3AIlSLWDfNOrgG5XdIxJUjsFQMFDvZbSn9HuaywqRoO7s%3D","message":"Database error when running migration latest for app core","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67","version":"21.0.0.18","exception":{"Exception":"Exception","Message":"Database error when running migration latest for app core","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Updater.php","line":307,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->","args":[]},{"file":"/var/www/html/lib/private/Updater.php","line":251,"function":"doCoreUpgrade","class":"OC\\Updater","type":"->","args":[]},{"file":"/var/www/html/lib/private/Updater.php","line":130,"function":"doUpgrade","class":"OC\\Updater","type":"->","args":["22.0.0.11","21.0.0.18"]},{"file":"/var/www/html/core/ajax/update.php","line":200,"function":"upgrade","class":"OC\\Updater","type":"->","args":[]}],"File":"/var/www/html/lib/private/DB/MigrationService.php","Line":429,"Previous":{"Exception":"Doctrine\\DBAL\\Exception\\DriverException","Message":"An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1932 Table 'nextcloud.oc_known_users' doesn't exist in engine","Code":1932,"Trace":[{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1728,"function":"convert","class":"Doctrine\\DBAL\\Driver\\API\\MySQL\\ExceptionConverter","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDO\\Exception"},{"__class__":"Doctrine\\DBAL\\Query"}]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1667,"function":"handleDriverException","class":"Doctrine\\DBAL\\Connection","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDO\\Exception"},{"__class__":"Doctrine\\DBAL\\Query"}]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1040,"function":"convertExceptionDuringQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDO\\Exception"},"CREATE INDEX ku_known_user ON oc_known_users (known_user)",[],[]]},{"file":"/var/www/html/lib/private/DB/Connection.php","line":231,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["CREATE INDEX ku_known_user ON oc_known_users (known_user)",[],[],null]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1757,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["CREATE INDEX ku_known_user ON oc_known_users (known_user)"]},{"file":"/var/www/html/lib/private/DB/Migrator.php","line":175,"function":"query","class":"Doctrine\\DBAL\\Connection","type":"->","args":["CREATE INDEX ku_known_user ON oc_known_users (known_user)"]},{"file":"/var/www/html/lib/private/DB/Migrator.php","line":76,"function":"applySchema","class":"OC\\DB\\Migrator","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Schema\\Schema"}]},{"file":"/var/www/html/lib/private/DB/Connection.php","line":527,"function":"migrate","class":"OC\\DB\\Migrator","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Schema\\Schema"}]},{"file":"/var/www/html/lib/private/DB/MigrationService.php","line":540,"function":"migrateToSchema","class":"OC\\DB\\Connection","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Schema\\Schema"}]},{"file":"/var/www/html/lib/private/DB/MigrationService.php","line":425,"function":"executeStep","class":"OC\\DB\\MigrationService","type":"->","args":["21000Date20210309185127",false]},{"file":"/var/www/html/lib/private/Updater.php","line":307,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->","args":[]},{"file":"/var/www/html/lib/private/Updater.php","line":251,"function":"doCoreUpgrade","class":"OC\\Updater","type":"->","args":[]},{"file":"/var/www/html/lib/private/Updater.php","line":130,"function":"doUpgrade","class":"OC\\Updater","type":"->","args":["22.0.0.11","21.0.0.18"]},{"file":"/var/www/html/core/ajax/update.php","line":200,"function":"upgrade","class":"OC\\Updater","type":"->","args":[]}],"File":"/var/www/html/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php","Line":114,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDO\\Exception","Message":"SQLSTATE[42S02]: Base table or view not found: 1932 Table 'nextcloud.oc_known_users' doesn't exist in engine","Code":1932,"Trace":[{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","line":87,"function":"new","class":"Doctrine\\DBAL\\Driver\\PDO\\Exception","type":"::","args":[{"errorInfo":["42S02",1932,"Table 'nextcloud.oc_known_users' doesn't exist in engine"],"__class__":"PDOException"}]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1035,"function":"query","class":"Doctrine\\DBAL\\Driver\\PDO\\Connection","type":"->","args":["CREATE INDEX ku_known_user ON oc_known_users (known_user)"]},{"file":"/var/www/html/lib/private/DB/Connection.php","line":231,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["CREATE INDEX ku_known_user ON oc_known_users (known_user)",[],[],null]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1757,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["CREATE INDEX ku_known_user ON oc_known_users (known_user)"]},{"file":"/var/www/html/lib/private/DB/Migrator.php","line":175,"function":"query","class":"Doctrine\\DBAL\\Connection","type":"->","args":["CREATE INDEX ku_known_user ON oc_known_users (known_user)"]},{"file":"/var/www/html/lib/private/DB/Migrator.php","line":76,"function":"applySchema","class":"OC\\DB\\Migrator","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Schema\\Schema"}]},{"file":"/var/www/html/lib/private/DB/Connection.php","line":527,"function":"migrate","class":"OC\\DB\\Migrator","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Schema\\Schema"}]},{"file":"/var/www/html/lib/private/DB/MigrationService.php","line":540,"function":"migrateToSchema","class":"OC\\DB\\Connection","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Schema\\Schema"}]},{"file":"/var/www/html/lib/private/DB/MigrationService.php","line":425,"function":"executeStep","class":"OC\\DB\\MigrationService","type":"->","args":["21000Date20210309185127",false]},{"file":"/var/www/html/lib/private/Updater.php","line":307,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->","args":[]},{"file":"/var/www/html/lib/private/Updater.php","line":251,"function":"doCoreUpgrade","class":"OC\\Updater","type":"->","args":[]},{"file":"/var/www/html/lib/private/Updater.php","line":130,"function":"doUpgrade","class":"OC\\Updater","type":"->","args":["22.0.0.11","21.0.0.18"]},{"file":"/var/www/html/core/ajax/update.php","line":200,"function":"upgrade","class":"OC\\Updater","type":"->","args":[]}],"File":"/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php","Line":26,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[42S02]: Base table or view not found: 1932 Table 'nextcloud.oc_known_users' doesn't exist in engine","Code":"42S02","Trace":[{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","line":82,"function":"query","class":"PDO","type":"->","args":["CREATE INDEX ku_known_user ON oc_known_users (known_user)"]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1035,"function":"query","class":"Doctrine\\DBAL\\Driver\\PDO\\Connection","type":"->","args":["CREATE INDEX ku_known_user ON oc_known_users (known_user)"]},{"file":"/var/www/html/lib/private/DB/Connection.php","line":231,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["CREATE INDEX ku_known_user ON oc_known_users (known_user)",[],[],null]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1757,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["CREATE INDEX ku_known_user ON oc_known_users (known_user)"]},{"file":"/var/www/html/lib/private/DB/Migrator.php","line":175,"function":"query","class":"Doctrine\\DBAL\\Connection","type":"->","args":["CREATE INDEX ku_known_user ON oc_known_users (known_user)"]},{"file":"/var/www/html/lib/private/DB/Migrator.php","line":76,"function":"applySchema","class":"OC\\DB\\Migrator","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Schema\\Schema"}]},{"file":"/var/www/html/lib/private/DB/Connection.php","line":527,"function":"migrate","class":"OC\\DB\\Migrator","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Schema\\Schema"}]},{"file":"/var/www/html/lib/private/DB/MigrationService.php","line":540,"function":"migrateToSchema","class":"OC\\DB\\Connection","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Schema\\Schema"}]},{"file":"/var/www/html/lib/private/DB/MigrationService.php","line":425,"function":"executeStep","class":"OC\\DB\\MigrationService","type":"->","args":["21000Date20210309185127",false]},{"file":"/var/www/html/lib/private/Updater.php","line":307,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->","args":[]},{"file":"/var/www/html/lib/private/Updater.php","line":251,"function":"doCoreUpgrade","class":"OC\\Updater","type":"->","args":[]},{"file":"/var/www/html/lib/private/Updater.php","line":130,"function":"doUpgrade","class":"OC\\Updater","type":"->","args":["22.0.0.11","21.0.0.18"]},{"file":"/var/www/html/core/ajax/update.php","line":200,"function":"upgrade","class":"OC\\Updater","type":"->","args":[]}],"File":"/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","Line":82}}},"CustomMessage":"Database error when running migration latest for app core"}}
{"reqId":"0QIylBeBODN18b9la1jz","level":3,"time":"2021-07-13T06:52:12+00:00","remoteAddr":"ipaddress","user":"--","app":"updater","method":"GET","url":"/core/ajax/update.php?requesttoken=YBP8K1y1V5dStQQqgs9JhmdaREueHlqEbZHjr9wcePY%3D%3AIlSLWDfNOrgG5XdIxJUjsFQMFDvZbSn9HuaywqRoO7s%3D","message":"\\OC\\Updater::failure: Exception: Database error when running migration latest for app core","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67","version":"21.0.0.18"}
{"reqId":"0QIylBeBODN18b9la1jz","level":3,"time":"2021-07-13T06:52:12+00:00","remoteAddr":"ipaddress","user":"--","app":"updater","method":"GET","url":"/core/ajax/update.php?requesttoken=YBP8K1y1V5dStQQqgs9JhmdaREueHlqEbZHjr9wcePY%3D%3AIlSLWDfNOrgG5XdIxJUjsFQMFDvZbSn9HuaywqRoO7s%3D","message":"\\OC\\Updater::updateEnd: Update failed","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67","version":"21.0.0.18"}
{"reqId":"0QIylBeBODN18b9la1jz","level":1,"time":"2021-07-13T06:52:12+00:00","remoteAddr":"ipaddress","user":"--","app":"updater","method":"GET","url":"/core/ajax/update.php?requesttoken=YBP8K1y1V5dStQQqgs9JhmdaREueHlqEbZHjr9wcePY%3D%3AIlSLWDfNOrgG5XdIxJUjsFQMFDvZbSn9HuaywqRoO7s%3D","message":"\\OC\\Updater::maintenanceActive: Maintenance mode is kept active","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67","version":"21.0.0.18"}
{"reqId":"0QIylBeBODN18b9la1jz","level":1,"time":"2021-07-13T06:52:12+00:00","remoteAddr":"ipaddress","user":"--","app":"updater","method":"GET","url":"/core/ajax/update.php?requesttoken=YBP8K1y1V5dStQQqgs9JhmdaREueHlqEbZHjr9wcePY%3D%3AIlSLWDfNOrgG5XdIxJUjsFQMFDvZbSn9HuaywqRoO7s%3D","message":"\\OC\\Updater::resetLogLevel: Reset log level to Warning(2)","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67","version":"21.0.0.18"}
root@5775046331a7:/var/www/html/data#

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'trusted_proxies' =>
  array (
    0 => 'ipaddress',
    1 => 'ipaddress',
  ),
  'overwritehost' => 'servername',
  'overwriteprotocol' => 'https',
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'och4e5d1n61q',
  'passwordsalt' => 'iF6y39206Es1Ne6QsnN7cT6xMMovWr',
  'secret' => 'Vt1mCHzETCMdMqaeOJcX1KhfQOtzdjR17/ZLfu9L6oDA/34e',
  'trusted_domains' =>
  array (
    0 => 'servername:81',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '21.0.0.18',
  'overwrite.cli.url' => 'http://servername:81',
  'dbname' => 'nextcloud',
  'dbhost' => 'servername:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_admin',
  'dbpassword' => '5XQ7jSPME1EFZ65HdevFRJ5RV47eae',
  'installed' => true,
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'mail_domain' => 'servername',
  'mail_from_address' => 'testcloud',
  'mail_smtpmode' => 'smtp',
  'mail_smtphost' => 'servername',
  'mail_smtpport' => '25',
  'mail_sendmailmode' => 'smtp',
  'updater.release.channel' => 'stable',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'app_install_overwrite' =>
  array (
    0 => 'spreed',
    1 => 'files_inotify',
    2 => 'suspicious_login',
    3 => 'bruteforcesettings',
    4 => 'epubreader',
  ),
);
1 Like

I’m getting the same error message.

I’m also facing the same issue, although I’m running Docker Nextcloud 21.0.3.1 going to 22.0.0.11. My error log is similar to kazzic555.

I am getting the same error currently. Using docker swarm however but when upgrading the image to the latest nextcloud this happens.

I cannot downgrade either

so i found This information and found someone was able to fix it by downgrading their mariadb to 10.5. I appended the mariadb to 10.5 and the upgrade is going through now and I can use Nextcloud 22.

It looks as if this is a weird error by both nextcloud and mariadb. Definitely going to start appending major.minor versions from now on

7 Likes

This solved the problem for me, many thanks !

1 Like

Thanks for replying but my version of Mariadb is 10.5.9.

Good to know not to upgrade beyond 10.5.x though.

Upgrading is always a thrill… thanks for providing the solution this time :slight_smile:

Thanks a ton, fixed it for me too… I’m always scared of an upgrade.

Thank you so much! This needs to be the first result when searching for error.

“Exception: Database error when running migration latest for app core”

P.S. I literally created an account to post this!