Skip to content

Update from 10.0.10 to 10.1.0 on Debian gives error "Doctrine\DBAL\Exception\DriverException" #34572

Closed

Description

@jonasc

Steps to reproduce

  1. Upgrade package on Debian from 10.0.10-1+1.1 to 10.1.0-1+1.1
  2. Run occ upgrade

Expected behaviour

Upgrade should run through without error.

Actual behaviour

The following is the output I get:

% sudo -u www-data php ./occ upgrade                                                                                                                                                                                                             :(
ownCloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
2019-02-20T14:14:03+00:00 Set log level to debug
2019-02-20T14:14:03+00:00 Repair step: Upgrade app code from the marketplace
2019-02-20T14:14:03+00:00 Repair info: Using market to update existing apps
2019-02-20T14:14:03+00:00 Repair info: Attempting to update the following existing compatible apps from market: calendar, contacts, dav, federatedfilesharing, files, files_external, files_sharing, market
2019-02-20T14:14:03+00:00 Repair info: Fetching app from market: calendar
2019-02-20T14:14:04+00:00 Repair info:
2019-02-20T14:14:04+00:00 Repair info: Fetching app from market: contacts
2019-02-20T14:14:04+00:00 Repair info:
2019-02-20T14:14:04+00:00 Repair info: Fetching app from market: dav
2019-02-20T14:14:04+00:00 Repair info: App (dav) is not known at the marketplace.
2019-02-20T14:14:04+00:00 Repair info: Fetching app from market: federatedfilesharing
2019-02-20T14:14:04+00:00 Repair info: App (federatedfilesharing) is not known at the marketplace.
2019-02-20T14:14:04+00:00 Repair info: Fetching app from market: files
2019-02-20T14:14:04+00:00 Repair info: App (files) is not known at the marketplace.
2019-02-20T14:14:04+00:00 Repair info: Fetching app from market: files_external
2019-02-20T14:14:04+00:00 Repair info: App (files_external) is not known at the marketplace.
2019-02-20T14:14:04+00:00 Repair info: Fetching app from market: files_sharing
2019-02-20T14:14:04+00:00 Repair info: App (files_sharing) is not known at the marketplace.
2019-02-20T14:14:04+00:00 Repair info: Fetching app from market: market
2019-02-20T14:14:04+00:00 Repair info:
2019-02-20T14:14:04+00:00 Repair info: App was not updated: calendar
2019-02-20T14:14:04+00:00 Repair info: App was not updated: contacts
2019-02-20T14:14:04+00:00 Repair info: App was not updated: dav
2019-02-20T14:14:04+00:00 Repair info: App was not updated: federatedfilesharing
2019-02-20T14:14:04+00:00 Repair info: App was not updated: files
2019-02-20T14:14:04+00:00 Repair info: App was not updated: files_external
2019-02-20T14:14:04+00:00 Repair info: App was not updated: files_sharing
2019-02-20T14:14:04+00:00 Repair info: App was not updated: market
2019-02-20T14:14:04+00:00 Repair step: Repair MySQL database engine
2019-02-20T14:14:04+00:00 Repair step: Repair MySQL collation
2019-02-20T14:14:04+00:00 Repair info: All tables already have the correct collation -> nothing to do
2019-02-20T14:14:04+00:00 Repair step: Repair SQLite autoincrement
2019-02-20T14:14:04+00:00 Repair step: Repair orphaned reshare
2019-02-20T14:14:04+00:00 Repair step: Repair duplicate entries in oc_lucene_status
2019-02-20T14:14:04+00:00 Repair info: removing duplicate entries from lucene_status
2019-02-20T14:14:04+00:00 Updating database schema
2019-02-20T14:14:04+00:00 Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'ALTER TABLE oc_persistent_locks ADD CONSTRAINT FK_F0C3D55B93CB796C FOREIGN KEY (file_id) REFERENCES oc_filecache (fileid) ON DELETE CASCADE':

SQLSTATE[HY000]: General error: 1005 Can't create table 'DB_NAME_REMOVED.#sql-613_1e671' (errno: 150)
2019-02-20T14:14:04+00:00 Update failed
2019-02-20T14:14:04+00:00 Maintenance mode is kept active
2019-02-20T14:14:04+00:00 Reset log level

Server configuration

Operating system: Debian 8.11

Web server: nginx 1.6

Database: mysql 5.5

PHP version: 5.6

New ownCloud version: 10.1.0.4

Updated from an older ownCloud or fresh install: Update from 10.0.10

Where did you install ownCloud from: Official Debian release channel trough apt

Signing status (ownCloud 9.0 and above): ?

Can't access integrity check page.

The content of config/config.php:

<?php
$CONFIG = array (
  'instanceid' => 'ocVALUE_REMOVED',
  'passwordsalt' => 'VALUE_REMOVED',
  'datadirectory' => '/mnt/noexec/nginx/VALUE_REMOVED',
  'dbtype' => 'mysql',
  'version' => '10.0.10.4',
  'dbname' => 'VALUE_REMOVED',
  'dbhost' => '127.0.0.1',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'VALUE_REMOVED',
  'dbpassword' => 'VALUE_REMOVED',
  'installed' => true,
  'forcessl' => true,
  'theme' => '',
  'maintenance' => false,
  'loglevel' => 0,
  'mail_from_address' => 'cloud',
  'mail_smtpmode' => 'php',
  'mail_domain' => 'VALUE_REMOVED',
  'secret' => 'VALUE_REMOVED',
  'trusted_domains' =>
  array (
    0 => 'VALUE_REMOVED',
  ),
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'updatechecker' => false,
  'trashbin_retention_obligation' => 'auto',
);

List of activated apps:

  - calendar: 1.6.1
  - contacts: 1.5.5
  - dav: 0.4.0
  - federatedfilesharing: 0.3.1
  - files: 1.5.1
  - files_external: 0.7.1
  - files_sharing: 0.11.0
  - market: 0.2.5

Are you using external storage, if yes which one: no

Are you using encryption: no

Are you using an external user-backend, if yes which one: no

Logs

ownCloud log (data/owncloud.log)

{"reqId":"fDTQiYGQOBtjHMECUZgj","level":1,"time":"2019-02-20T14:10:25+00:00","remoteAddr":"","user":"--","app":"cli","method":"--","url":"--","message":"Memcache \\OC\\Memcache\\APCu not available for local cache"}
{"reqId":"fDTQiYGQOBtjHMECUZgj","level":1,"time":"2019-02-20T14:10:25+00:00","remoteAddr":"","user":"--","app":"cli","method":"--","url":"--","message":"Memcache \\OC\\Memcache\\APCu not available for distributed cache"}
{"reqId":"fDTQiYGQOBtjHMECUZgj","level":3,"time":"2019-02-20T14:10:27+00:00","remoteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"Undefined variable: self at \/var\/www\/owncloud\/core\/Command\/Upgrade.php#245"}
{"reqId":"fDTQiYGQOBtjHMECUZgj","level":0,"time":"2019-02-20T14:10:27+00:00","remoteAddr":"","user":"--","app":"core","method":"--","url":"--","message":"starting upgrade from 10.0.10.4 to 10.1.0.4"}
{"reqId":"fDTQiYGQOBtjHMECUZgj","level":0,"time":"2019-02-20T14:10:36+00:00","remoteAddr":"","user":"--","app":"core","method":"--","url":"--","message":"Migrations: starting 20180607072706 from app core"}
{"reqId":"fDTQiYGQOBtjHMECUZgj","level":3,"time":"2019-02-20T14:10:41+00:00","remoteAddr":"","user":"--","app":"core","method":"--","url":"--","message":"Exception: {\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\DriverException\",\"Message\":\"An exception occurred while executing 'ALTER TABLE oc_persistent_locks ADD CONSTRAINT FK_F0C3D55B93CB796C FOREIGN KEY (file_id) REFERENCES oc_filecache (fileid) ON DELETE CASCADE':\\n\\nSQLSTATE[HY000]: General error: 1005 Can't create table 'DB_NAME_REMOVED.#sql-613_1e661' (errno: 150)\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/DBALException.php(128): Doctrine\\\\DBAL\\\\Driver\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Connection.php(964): Doctrine\\\\DBAL\\\\DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOMySql\\\\Driver), Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException), 'ALTER TABLE oc_...')\\n#2 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/DB\\\/Migrator.php(198): Doctrine\\\\DBAL\\\\Connection->query('ALTER TABLE oc_...')\\n#3 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/DB\\\/Migrator.php(80): OC\\\\DB\\\\Migrator->applySchema(Object(Doctrine\\\\DBAL\\\\Schema\\\\Schema))\\n#4 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/DB\\\/Connection.php(434): OC\\\\DB\\\\Migrator->migrate(Object(Doctrine\\\\DBAL\\\\Schema\\\\Schema))\\n#5 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/DB\\\/MigrationService.php(412): OC\\\\DB\\\\Connection->migrateToSchema(Object(Doctrine\\\\DBAL\\\\Schema\\\\Schema))\\n#6 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/DB\\\/MigrationService.php(366): OC\\\\DB\\\\MigrationService->executeStep(20180607072706)\\n#7 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Updater.php(301): OC\\\\DB\\\\MigrationService->migrate()\\n#8 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Updater.php(255): OC\\\\Updater->doCoreUpgrade()\\n#9 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Updater.php(112): OC\\\\Updater->doUpgrade('10.1.0.4', '10.0.10.4')\\n#10 \\\/var\\\/www\\\/owncloud\\\/core\\\/Command\\\/Upgrade.php(261): OC\\\\Updater->upgrade()\\n#11 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/symfony\\\/console\\\/Command\\\/Command.php(255): OC\\\\Core\\\\Command\\\\Upgrade->execute(Object(Symfony\\\\Component\\\\Console\\\\Input\\\\ArgvInput), Object(Symfony\\\\Component\\\\Console\\\\Output\\\\ConsoleOutput))\\n#12 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/symfony\\\/console\\\/Application.php(953): Symfony\\\\Component\\\\Console\\\\Command\\\\Command->run(Object(Symfony\\\\Component\\\\Console\\\\Input\\\\ArgvInput), Object(Symfony\\\\Component\\\\Console\\\\Output\\\\ConsoleOutput))\\n#13 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/symfony\\\/console\\\/Application.php(248): Symfony\\\\Component\\\\Console\\\\Application->doRunCommand(Object(OC\\\\Core\\\\Command\\\\Upgrade), Object(Symfony\\\\Component\\\\Console\\\\Input\\\\ArgvInput), Object(Symfony\\\\Component\\\\Console\\\\Output\\\\ConsoleOutput))\\n#14 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/symfony\\\/console\\\/Application.php(148): Symfony\\\\Component\\\\Console\\\\Application->doRun(Object(Symfony\\\\Component\\\\Console\\\\Input\\\\ArgvInput), Object(Symfony\\\\Component\\\\Console\\\\Output\\\\ConsoleOutput))\\n#15 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Console\\\/Application.php(161): Symfony\\\\Component\\\\Console\\\\Application->run(NULL, NULL)\\n#16 \\\/var\\\/www\\\/owncloud\\\/console.php(106): OC\\\\Console\\\\Application->run()\\n#17 \\\/var\\\/www\\\/owncloud\\\/occ(11): require_once('\\\/var\\\/www\\\/ownclo...')\\n#18 {main}\",\"File\":\"\\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/AbstractMySQLDriver.php\",\"Line\":115}"}

Activity

  1. ownclouders commented on Feb 20, 2019

    @ownclouders
    Contributor

    GitMate.io thinks the contributors most likely able to help are @ownclouders, and @sharidas.

    Possibly related issues are #28027 (Updating 10.0.0 to 10.0.1), #21047 (Doctrine\DBAL\Exception\DriverException), #30076 (Doctrine\DBAL\Exception\DriverException: error), #16936 (8.1 fails on Debian 8.0), and #27822 (Updating to 10.0.0 from 9.1 failure.).

  2. Ghoschdi commented on Feb 20, 2019

    @Ghoschdi

    I had the same error until I realized that the table 'oc_filecache' was created with my mariaDBs default engine ARIA instead of InnoDB (for whatever reason).
    If I am not mistaken only InnoDB supports Foreign Keys and ARIA not (and OC only supports InnoDB).
    What I did:

    1. Changed the engine: ALTER TABLE 'oc_filecache' ENGINE = InnoDB;,
    2. deleted the table 'oc_persistent_locks'
    3. startet the upgrade again

    And it worked.
    Maybe it would be worthwhile to check if the engine of all tables is really set to InnoDB because OC only supports this?

  3. lbeck88 commented on Feb 20, 2019

    @lbeck88

    Getting the same issue, tried to follow the steps from @Ghoschdi but mine still errors at the same place.

    Just to add, table engine is InnoDB

  4. lbeck88 commented on Feb 20, 2019

    @lbeck88

    Fixed my error.
    fileid in oc_filecache was int(11) while file_id in oc_persistent_locks was bigint(20).

    Changed fileid to be bigint(20), deleted the oc_persistent_locks table and ran occ upgrade again.

  5. jonasc commented on Feb 20, 2019

    @jonasc
    Author

    @lbeck88 Thanks for your comment. This fixed the problem for me.

    ALTER TABLE oc_filecache MODIFY fileid bigint(20) NOT NULL AUTO_INCREMENT;
    
  6. jvillafanez commented on Feb 21, 2019

    @jvillafanez
    Member

    Guys, DON'T touch manually the DB unless devs tell you that it's safe to do so.

    "core/Migrations/Version20170804201253.php" should have been executed. You can check in the "oc_migrations" table if that migration has been run or not.
    occ migration:status also helps to check if there are migrations that haven't been run.

    The problem here isn't that the update fails, is that a migration failed to run, which causes problems because your DB state isn't the expected one.
    As you can see in the migration code, there are other tables whose types have been changed to bigint. You'll likely run into problems in the future for the same reason unless the migration is executed. This can be extended to any other migration.

  7. lbeck88 commented on Feb 21, 2019

    @lbeck88

    @jvillafanez I'm currently at the latest migration step:

    >> App:                                                core
    >> Version Table Name:                                 oc_migrations
    >> Migrations Namespace:                               OC\Migrations
    >> Migrations Directory:                               /var/www/owncloud/core/Migrations
    >> Previous Version:                                   20181017120818
    >> Current Version:                                    20181113071753
    >> Next Version:                                       Already at latest migration step
    >> Latest Version:                                     20181113071753
    >> Executed Migrations:                                24
    >> Executed Unavailable Migrations:                    24
    >> Available Migrations:                               24
    >> New Migrations:                                     24
    
  8. jonasc commented on Feb 21, 2019

    @jonasc
    Author

    @jvillafanez, @lbeck88
    For me core also is up to date but for dav I get

    $ ./occ migration:status dav
        >> App:                                                dav
        >> Version Table Name:                                 oc_migrations
        >> Migrations Namespace:                               OCA\dav\Migrations
        >> Migrations Directory:                               /var/www/owncloud/apps/dav/appinfo/Migrations
        >> Previous Version:                                   20170927201245
        >> Current Version:                                    20180622095921
        >> Next Version:                                       20181115210344
        >> Latest Version:                                     20181115210344
        >> Executed Migrations:                                10
        >> Executed Unavailable Migrations:                    10
        >> Available Migrations:                               11
        >> New Migrations:                                     11
    

    I looked around a bit and then decided to continue the migration process with ./occ migration:migrate dav. Was that a good choice or did I make things worse with this 😱?
    After running it it tells me that also the dav app is up to date.

  9. Ghoschdi commented on Feb 21, 2019

    @Ghoschdi

    @jvillafanez : That makes sense and I checked the migration status, which claimed everything was run properly. That said, i found more tables that do not use the InnoDB engine, which is weird since i thought and read OC only supports InnoDB since 9.x.
    So best to run a maintenance:repair or change the tables manually?

  10. jvillafanez commented on Feb 21, 2019

    @jvillafanez
    Member

    I looked around a bit and then decided to continue the migration process with ./occ migration:migrate dav. Was that a good choice or did I make things worse with this 😱?
    After running it it tells me that also the dav app is up to date.

    I think your missing migration changes to bigint several ids for contacts and calendar. You'll probably need it at somepoint.

    @jvillafanez : That makes sense and I checked the migration status, which claimed everything was run properly. That said, i found more tables that do not use the InnoDB engine, which is weird since i thought and read OC only supports InnoDB since 9.x.
    So best to run a maintenance:repair or change the tables manually?

    I don't think ownCloud is explicitly setting the innoDB engine in any place. That said, there is a repair step (I guess the "maintenance:repair should run it) to change from MyISAM to innoDB. If MariaDB is setting another engine by default, it won't probably be repaired by the occ repair.

    For now, I'd recommend you to try to set the innoDB engine to be used by default. If that isn't possible, try the "maintenance:repair" (note that it won't likely work, so double-check it in the DB), and finally change it manually.

  11. Ghoschdi commented on Feb 21, 2019

    @Ghoschdi

    I set InnoDB to default on my server now (and was kind of surprised it still was ARIA). I also found the repair routine but it is limited to change MyISAM to InnoDB as you said. So I just executed the SQL myself for all the tables. Thanks for the help!

  12. stale commented on Sep 20, 2021

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions