Skip to content

Update 10.0.8.5 to 10.1.0 failed on shared hoster #34598

Closed

Description

Hello, OC is really giving me a hard time every time I try to update it. It would really be a great step forward if update process could be noob-safe.
I found my actual update errors in similar ways on the net, but could not figure out how to solve them in my case. Can anybody help? Thanks and regards, Pingpong

owncloud_log.zip

Steps to reproduce

  1. Uploaded new files to oc directory
  2. Started update with web browser

Expected behaviour

Update my oc to 10.1.0

Actual behaviour

Update failed and gives error message:

Update vorbereiten
Log-Level auf "debug" gesetzt
Wartungsmodus eingeschaltet
Reperaturwarnung:Market app is unavailable for updating of apps. Please update manually, see https://doc.owncloud.org/server/10.1/go.php?to=admin-marketplace-apps
Das Datenbankschema wird aktualisiert
Doctrine\DBAL\Schema\SchemaException: The table with name 'web143_db3.oc_persistent_locks' already exists.

Server configuration

Operating system:
unknown
Web server:
Apache
Database:
MYSQL
PHP version:
7.2
ownCloud version: (see ownCloud admin page)
10.0.8.5
Where did you install ownCloud from:
https://owncloud.org/download/
The content of config/config.php:

<?php
$CONFIG = array (
  'instanceid' => '***',
  'passwordsalt' => '***Y',
  'secret' => '***',
  'trusted_domains' => 
  array (
    0 => 'www.***.de',
    1 => '***.de',
  ),
  'datadirectory' => '/***/owncloud/data',
  'overwrite.cli.url' => 'http://www.***.de',
  'dbtype' => 'mysql',
  'version' => '10.0.8.5',
  'dbname' => '***',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => '***',
  'dbpassword' => '***',
  'installed' => true,
  'forcessl' => true,
  'forceSSLforSubdomains' => true,
  'mail_from_address' => '***',
  'mail_smtpmode' => 'php',
  'mail_domain' => '***.de',
  'theme' => '',
  'loglevel' => 0,
  'maintenance' => false,
  'htaccess.RewriteBase' => '/',
  'updater.secret' => '***',
);

Log in to the web-UI with an administrator account and click on
'admin' -> 'Generate Config Report' -> 'Download ownCloud config report'
not possible
List of activated apps:
non
Are you using external storage, if yes which one: local/smb/sftp/...
no
Are you using encryption: yes/no
don't know
Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
no

Client configuration

Browser
Vivaldi 2.3.1440.48
Operating system:
Win 10 Pro 1809

Logs

Web server error log

[Tue Feb 19 13:09:15 2019] [error] [client AH02032: Hostname www..de: provided via SNI and hostname www..de provided via HTTP are different
[Thu Feb 21 23:47:18 2019] [error] [client AH02032: Hostname www.
.de:*** provided via SNI and hostname www..de provided via HTTP are different
[Fri Feb 22 18:44:48 2019] [error] [client 188.193.149.19:2443] AH01630: client denied by server configuration: /
/owncloud/data/htaccesstest.txt
[Fri Feb 22 18:45:59 2019] [error] [client 188.193.149.19:2458] AH01630: client denied by server configuration: //owncloud/data/htaccesstest.txt
[Fri Feb 22 19:36:30 2019] [error] [client 188.193.149.19:2645] AH01630: client denied by server configuration: /
/owncloud/data/htaccesstest.txt
[Fri Feb 22 20:58:51 2019] [error] [client 188.193.149.19:3999] script '/***/owncloud/index.php' not found or unable to stat

ownCloud log (data/owncloud.log)

see attached file owncloud_log.zip

Activity

  1. ownclouders commented on Feb 23, 2019

    @ownclouders
    Contributor

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

    Possibly related issues are #18350 (DB-Schema update fails, 8.1.0 to 8.1.1), #17768 ( 8.1.0 update Failed), #18032 (massive/strange db updates after upgrade to 8.1.0), #14677 (Upgrade failing 7.0.5 to 8.0.1 when keeping apps folder), and #4857 (Updater fails to update to 5.0.11 (unable to move ...)).

  2. PVince81 commented on Feb 25, 2019

    @PVince81
    Contributor

    hmm this was observed before but could not be reproduced: #33963

    it failed on the same table, so there's likely something that was similar in your env compared to that other env

  3. PVince81 commented on Feb 25, 2019

    @PVince81
    Contributor

    from what I see there was an error before the migration even ran:

    {"reqId":"XHBKjCUR4C0AAEM0-nEAAAAF","level":0,"time":"2019-02-22T19:16:28+00:00","remoteAddr":"***","user":"--","app":"core","method":"GET","url":"\/core\/ajax\/update.php?requesttoken=UCAHHyIjIWleBHtjcT50GyMIPDJ9MhgfeSwbEwUOCw4%3D%3Aimm4hAN0iCP93y8%2FhLKZ%2BvOO6EBkttLvkwedzwzymZw%3D","message":"Migrations: starting 20180607072706 from app core"}
    {"reqId":"XHBKjCUR4C0AAEM0-nEAAAAF","level":3,"time":"2019-02-22T19:16:29+00:00","remoteAddr":"***","user":"--","app":"core","method":"GET","url":"\/core\/ajax\/update.php?requesttoken=UCAHHyIjIWleBHtjcT50GyMIPDJ9MhgfeSwbEwUOCw4%3D%3Aimm4hAN0iCP93y8%2FhLKZ%2BvOO6EBkttLvkwedzwzymZw%3D","message":"Exception: {\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\ConnectionException\",\"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[42000]: Syntax error or access violation: 1142 REFERENCES command denied to user 'web143_3'@'localhost' for table 'oc_filecache'\",\"Code\":0,\"Trace\":\"
    #0 \***\/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 \***\/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 \***\/owncloud\\\/lib\\\/private\\\/DB\\\/Migrator.php(198): Doctrine\\\\DBAL\\\\Connection->query('ALTER TABLE oc_...')\\n
    #3 \***\/owncloud\\\/lib\\\/private\\\/DB\\\/Migrator.php(80): OC\\\\DB\\\\Migrator->applySchema(Object(Doctrine\\\\DBAL\\\\Schema\\\\Schema))\\n
    #4 \***\/owncloud\\\/lib\\\/private\\\/DB\\\/Connection.php(434): OC\\\\DB\\\\Migrator->migrate(Object(Doctrine\\\\DBAL\\\\Schema\\\\Schema))\\n
    #5 \***\/owncloud\\\/lib\\\/private\\\/DB\\\/MigrationService.php(412): OC\\\\DB\\\\Connection->migrateToSchema(Object(Doctrine\\\\DBAL\\\\Schema\\\\Schema))\\n
    #6 \***\/owncloud\\\/lib\\\/private\\\/DB\\\/MigrationService.php(366): OC\\\\DB\\\\MigrationService->executeStep(20180607072706)\\n
    #7 \***\/owncloud\\\/lib\\\/private\\\/Updater.php(301): OC\\\\DB\\\\MigrationService->migrate()\\n
    #8 \***\/owncloud\\\/lib\\\/private\\\/Updater.php(255): OC\\\\Updater->doCoreUpgrade()\\n
    #9 \***\/owncloud\\\/lib\\\/private\\\/Updater.php(112): OC\\\\Updater->doUpgrade('10.1.0.4', '10.0.8.5')\\n
    #10 \***\/owncloud\\\/core\\\/ajax\\\/update.php(189): OC\\\\Updater->upgrade()\\n
    #11 {main}\",\"File\":\"\***\/owncloud\\\/lib\\\/composer\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/AbstractMySQLDriver.php\",\"Line\":103}"}
    {"reqId":"XHBK9yUR4C0AAGNL0nwAAAAE","level":3,"time":"2019-02-22T19:18:15+00:00","remoteAddr":"***","user":"--","app":"index","method":"GET","url":"\/core\/js\/oc.js?v=dca6c4ff9b1c577139f248b0e13a8895","message":"Exception: {\"Exception\":\"OC\\\\NeedsUpdateException\",\"Message\":\"\",\"Code\":0,\"Trace\":\"#0 \***\/owncloud\\\/lib\\\/private\\\/legacy\\\/app.php(127): OC_App::loadApp('dav')\\n#1 \***\/owncloud\\\/lib\\\/private\\\/legacy\\\/util.php(147): OC_App::loadApps(Array)\\n#2 \***\/owncloud\\\/lib\\\/base.php(908): OC_Util::setupFS()\\n#3 \***\/owncloud\\\/index.php(54): OC::handleRequest()\\n#4 {main}\",\"File\":\"\***\/owncloud\\\/lib\\\/private\\\/legacy\\\/app.php\",\"Line\":191}"}
    {"reqId":"XHBLBCUR4C0AAAkFVR0AAAAI","level":3,"time":"2019-02-22T19:18:28+00:00","remoteAddr":"***","user":"--","app":"index","method":"GET","url":"\/core\/js\/oc.js?v=dca6c4ff9b1c577139f248b0e13a8895","message":"Exception: {\"Exception\":\"OC\\\\NeedsUpdateException\",\"Message\":\"\",\"Code\":0,\"Trace\":\"#0 \***\/owncloud\\\/lib\\\/private\\\/legacy\\\/app.php(127): OC_App::loadApp('dav')\\n#1 \***\/owncloud\\\/lib\\\/private\\\/legacy\\\/util.php(147): OC_App::loadApps(Array)\\n#2 \***\/owncloud\\\/lib\\\/base.php(908): OC_Util::setupFS()\\n#3 \***\/owncloud\\\/index.php(54): OC::handleRequest()\\n#4 {main}\",\"File\":\"\***\/owncloud\\\/lib\\\/private\\\/legacy\\\/app.php\",\"Line\":191}"}
    {"reqId":"XHBLCCUR4C0AAEuBUjIAAAAD","level":0,"time":"2019-02-22T19:18:32+00:00","remoteAddr":"***","user":"--","app":"core","method":"GET","url":"\/core\/ajax\/update.php?requesttoken=UX8fAD4hHShmC14oGg0PAz0qOgUxE2QKOUYPTEM9ElM%3D%3Ah2u%2BtCrqQLurXJC7vnMmgW3Zv%2FV42GU%2BGxEv2dLcYyc%3D","message":"starting upgrade from 10.0.8.5 to 10.1.0.4"}
    

    It looks like your user has no permissions to create foreign keys Syntax error or access violation: 1142 REFERENCES command denied to user 'web143_3'@'localhost' for table oc_filecache` but somehow this didn't stop the upgrade and it went through.

    From what I see you re-started the failed upgrade a second time:

    {"reqId":"XHBLCCUR4C0AAEuBUjIAAAAD","level":0,"time":"2019-02-22T19:18:32+00:00","remoteAddr":"***","user":"--","app":"core","method":"GET","url":"\/core\/ajax\/update.php?requesttoken=UX8fAD4hHShmC14oGg0PAz0qOgUxE2QKOUYPTEM9ElM%3D%3Ah2u%2BtCrqQLurXJC7vnMmgW3Zv%2FV42GU%2BGxEv2dLcYyc%3D","message":"Migrations: starting 20180607072706 from app core"}
    {"reqId":"XHBLCCUR4C0AAEuBUjIAAAAD","level":3,"time":"2019-02-22T19:18:32+00:00","remoteAddr":"***","user":"--","app":"core","method":"GET","url":"\/core\/ajax\/update.php?requesttoken=UX8fAD4hHShmC14oGg0PAz0qOgUxE2QKOUYPTEM9ElM%3D%3Ah2u%2BtCrqQLurXJC7vnMmgW3Zv%2FV42GU%2BGxEv2dLcYyc%3D","message":"Exception: {\"Exception\":\"Doctrine\\\\DBAL\\\\Schema\\\\SchemaException\",\"Message\":\"The table with name 'web143_db3.oc_persistent_locks' already exists.\",\"Code\":20,\"Trace\":\"#0 \***\/owncloud\\\/lib\\\/composer\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Schema\\\/Schema.php(132): Doctrine\\\\DBAL\\\\Schema\\\\SchemaException::tableAlreadyExists('web143_db3.oc_p...')\\n#1 \***\/owncloud\\\/lib\\\/composer\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Schema\\\/Schema.php(340): Doctrine\\\\DBAL\\\\Schema\\\\Schema->_addTable(Object(Doctrine\\\\DBAL\\\\Schema\\\\Table))\\n#2 \***\/owncloud\\\/core\\\/Migrations\\\/Version20180607072706.php(15): Doctrine\\\\DBAL\\\\Schema\\\\Schema->createTable('oc_persistent_l...')\\n#3 \***\/owncloud\\\/lib\\\/private\\\/DB\\\/MigrationService.php(411): OC\\\\Migrations\\\\Version20180607072706->changeSchema(Object(Doctrine\\\\DBAL\\\\Schema\\\\Schema), Array)\\n#4 \***\/owncloud\\\/lib\\\/private\\\/DB\\\/MigrationService.php(366): OC\\\\DB\\\\MigrationService->executeStep(20180607072706)\\n#5 \***\/owncloud\\\/lib\\\/private\\\/Updater.php(301): OC\\\\DB\\\\MigrationService->migrate()\\n#6 \***\/owncloud\\\/lib\\\/private\\\/Updater.php(255): OC\\\\Updater->doCoreUpgrade()\\n#7 \***\/owncloud\\\/lib\\\/private\\\/Updater.php(112): OC\\\\Updater->doUpgrade('10.1.0.4', '10.0.8.5')\\n#8 \***\/owncloud\\\/core\\\/ajax\\\/update.php(189): OC\\\\Updater->upgrade()\\n#9 {main}\",\"File\":\"\***\/owncloud\\\/lib\\\/composer\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Schema\\\/SchemaException.php\",\"Line\":109}"}
    {"reqId":"XHBLJiUR4C0AAGNL0n4AAAAE","level":3,"time":"2019-02-22T19:19:02+00:00","remoteAddr":"***","user":"--","app":"index","method":"GET","url":"\/core\/js\/oc.js?v=dca6c4ff9b1c577139f248b0e13a8895","message":"Exception: {\"Exception\":\"OC\\\\NeedsUpdateException\",\"Message\":\"\",\"Code\":0,\"Trace\":\"#0 \***\/owncloud\\\/lib\\\/private\\\/legacy\\\/app.php(127): OC_App::loadApp('dav')\\n#1 \***\/owncloud\\\/lib\\\/private\\\/legacy\\\/util.php(147): OC_App::loadApps(Array)\\n#2 \***\/owncloud\\\/lib\\\/base.php(908): OC_Util::setupFS()\\n#3 \***\/owncloud\\\/index.php(54): OC::handleRequest()\\n#4 {main}\",\"File\":\"\***\/owncloud\\\/lib\\\/private\\\/legacy\\\/app.php\",\"Line\":191}"}
    

    So the first upgrade did create the table but failed due to the permissions issue. Likely you are running OC on a shared hoster ?

    And the second run tried to recreate the failed table.

    Normally to retry an upgrade one needs to restore from backup to have the former database state.

    @DeepDiver1975 seems that migrations aren't atomic ? I'd expect the migration to roll back all operations (structure changes) that were done within the migration if one of the operations fail.

    We could try and mitigate this by adding a table existence check. However this wouldn't solve the foreign key issue.

  4. changed the title [-]Update 10.0.8.5 to 10.1.0 failed[/-] [+]Update 10.0.8.5 to 10.1.0 failed on shared hoster[/+] on Feb 25, 2019
  5. PVince81 commented on Feb 25, 2019

    @PVince81
    Contributor

    @Pingponguin did you install your ownCloud on a shared web hoster or on a local machine where you have root / admin access ?

    many things in your report seem to give hints that this might be a shared hoster.

    otherwise if you have admin access for the whole database server you should grant the "web143_db3" all privileges.

  6. patrickjahns commented on Feb 25, 2019

    @patrickjahns
    Contributor

    @Pingponguin
    Would you be able to provide some information on the tables in the database.
    Can you issue a describe oc_filecache; and describe oc_accounts; - or show from your mysql interface the row names and types?

    Is my oc installation and all the data lost now?

    The data is preserved on the server - the database we will work towards finding a solution

  7. VicDeo commented on Feb 28, 2019

    @VicDeo
    Contributor

    @Pingponguin
    could you ask you hoster whether it is possible to grant REFERENCES permission for the DB user from your config.php on this DB?
    Basically they need to run something like this:
    GRANT REFERENCES ON YOUR_DB_NAME.* TO 'YOUR_DB_USER'@'YOUR_DB_HOST';
    and then
    FLUSH PRIVILEGES;

    or check if it is possible on your own via cPanel https://www.youtube.com/watch?v=lXnvDD9j6Hs

  8. VicDeo commented on Feb 28, 2019

    @VicDeo
    Contributor

    also could be related to the different engines used for these two tables, like in #34572

    The parent and child tables must use the same storage engine.

    From here https://dev.mysql.com/doc/refman/5.6/en/create-table-foreign-keys.html

  9. jensregel commented on Jul 16, 2019

    @jensregel

    Any updates? I still have the same error when i upgrade to version 10.2.1.

    Doctrine\DBAL\Schema\SchemaException: The table with name 'owncloud.oc_persistent_locks' already exists

  10. yger commented on Sep 18, 2019

    @yger

    Any updates? I have the same error, which is fact is happening in two steps. First time you launch the occ upgrade, I have the error

    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: 1215 Cannot add foreign key constraint

    Then if you relaunch, the table is already created

    Doctrine\DBAL\Schema\SchemaException: The table with name 'cloud.oc_persistent_locks' already exists.

    Manually deleting the table persistent_lock is not solving the problem, and the upgrade can not be made

  11. jensregel commented on Sep 21, 2019

    @jensregel

    Any updates? I still have the same error when i upgrade to version 10.2.1.

    Doctrine\DBAL\Schema\SchemaException: The table with name 'owncloud.oc_persistent_locks' already exists

    I did it! The user of the owncloud MySQL database does not have GRANT REFERENCES permission to create a FOREIGN KEY. The update worked well after the fix.

  12. VicDeo commented on Sep 23, 2019

    @VicDeo
    Contributor
  13. usenkov999 commented on Feb 3, 2020

    @usenkov999

    Any updates? I still have the same error when i upgrade to version 10.2.1.
    Doctrine\DBAL\Schema\SchemaException: The table with name 'owncloud.oc_persistent_locks' already exists

    I did it! The user of the owncloud MySQL database does not have GRANT REFERENCES permission to create a FOREIGN KEY. The update worked well after the fix.

    For me it does not work
    Can you help me?
    Can you explain in detail what you do to fix it?

  14. thorec commented on May 3, 2020

    @thorec

    Fighting with the same issue on a different setup. The system is self hosted in Docker containers
    The system is still on OC 10.0.10 and it should be upgraded to 10.4.1.

    First run of occ upgrade results in this error

    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: 1215 Cannot add foreign key constraint
    

    Next upgrade run shows

    Doctrine\DBAL\Schema\SchemaException: The table with name 'owncloud.oc_persistent_locks' already exists
    

    Deleting the table and manipulate this migration file by changing 'unsigned' => true to 'unsigned' => false in the following section.

    		$table->addColumn('owner_account_id', Type::BIGINT, [
    			'notnull' => false,
    			'unsigned' => false,
    			'length' => 20,
    			'comment' => 'owner of the lock - FK to account table'
    		]);
    

    makes the upgrade work nicely however I can not foresee the side-effects of this change.
    Can someone give some advise whether this the right solution or what a better option might be, please?

    Can all of this being avoided if migrations are applied from version to versison (i.e 10.0 -> 10.1 -> 10.2 -> 10.3 -> 10.4)?

  15. VicDeo commented on May 11, 2020

    @VicDeo
    Contributor
  16. stale commented on Sep 19, 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.

  17. stale commented on Sep 20, 2021

    @stale

    This issue has been automatically closed.

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