nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.38k stars 4.07k forks source link

[Bug]: Upgrade to 29.0.2 fails -- Index name collides with the constraint on a table #46094

Closed fsch2 closed 4 months ago

fsch2 commented 4 months ago

⚠️ This issue respects the following points: ⚠️

Bug description

I am trying to upgrade from 28.0.6 to 29.0.2.

Web interface and upgrade via SSH running occ show the same behavior. The error message is "InvalidArgumentException: Index name "rd_wopi_token_idx" for table "nc_9337_richdocuments_wopi" collides with the constraint on table "nc_9337_officeonline_wopi"."

Steps to reproduce

Run ./occ upgrade:

user@host % ./occ upgrade 
The current PHP memory limit is below the recommended value of 512MB.
Nextcloud 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
Setting log level to debug
Turned on maintenance mode
Updating database schema
Updated database
InvalidArgumentException: Index name "rd_wopi_token_idx" for table "nc_9337_richdocuments_wopi" collides with the constraint on table "nc_9337_officeonline_wopi".
Update failed
Maintenance mode is kept active
Resetting log level

Expected behavior

Update completes successfully. Maybe also by deactivating some apps.

Installation method

Community Web installer on a VPS or web space

Nextcloud Server version

28

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 22 to 23)

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

Configuration report

user@host % ./occ config:list system                                                                                                                                             :(
The current PHP memory limit is below the recommended value of 512MB.
Nextcloud 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
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "my-nextcloud.de"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "28.0.6.1",
        "integrity.check.disabled": true,
        "default_language": "de",
        "default_locale": "de",
        "default_phone_region": "DE",
        "trashbin_retention_obligation": "auto, 30",
        "version_retention_obligation": "auto, 30",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "log_type": "file",
        "logfile": "\/dev\/null",
        "overwrite.cli.url": "http:\/\/my-nextcloud.de",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "nc_9337_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "mail_smtpmode": "smtp",
        "mail_smtpsecure": "ssl",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "LOGIN",
        "maintenance": true,
        "maintenance_window_start": 1,
        "theme": "",
        "loglevel": 2,
        "skeletondirectory": "\/home\/sites\/site100020970\/web\/my-nextcloud.de\/data\/skeleton",
        "app_install_overwrite": [
            "occweb"
        ],
        "updater.secret": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

The current PHP memory limit is below the recommended value of 512MB.
Nextcloud 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
Enabled:
  - activity: 2.21.1
  - announcementcenter: 6.8.1
  - bruteforcesettings: 2.9.0
  - cloud_federation_api: 1.12.0
  - comments: 1.19.0
  - contactsinteraction: 1.10.0
  - dav: 1.30.1
  - federatedfilesharing: 1.19.0
  - files: 2.1.0
  - files_pdfviewer: 2.10.0
  - files_reminders: 1.2.0
  - files_sharing: 1.21.0
  - files_trashbin: 1.19.0
  - files_versions: 1.22.0
  - logreader: 2.14.0
  - lookup_server_connector: 1.17.0
  - nextcloud_announcements: 1.18.0
  - notifications: 2.17.0
  - oauth2: 1.17.0
  - password_policy: 1.19.0
  - photos: 2.5.0
  - privacy: 1.13.0
  - provisioning_api: 1.19.0
  - recommendations: 2.1.0
  - related_resources: 1.4.0
  - serverinfo: 1.19.0
  - settings: 1.12.0
  - sharebymail: 1.19.0
  - systemtags: 1.19.0
  - text: 3.10.0
  - theming: 2.4.0
  - twofactor_backupcodes: 1.18.0
  - updatenotification: 1.19.1
  - user_status: 1.9.0
  - viewer: 2.3.0
  - workflowengine: 2.11.0
Disabled:
  - admin_audit: 1.19.0
  - circles: 29.0.0-dev (installed 27.0.1)
  - dashboard: 7.9.0 (installed 7.0.0)
  - encryption: 2.17.0
  - federation: 1.19.0 (installed 1.17.0)
  - files_downloadlimit: 2.0.0
  - files_external: 1.21.0
  - files_rightclick: 0.15.1 (installed 1.6.0)
  - firstrunwizard: 2.18.0 (installed 2.8.0)
  - support: 1.12.0 (installed 1.10.1)
  - survey_client: 1.17.0 (installed 1.10.0)
  - suspicious_login: 7.0.0
  - twofactor_totp: 11.0.0-dev
  - user_ldap: 1.20.0
  - weather_status: 1.9.0 (installed 1.7.0)

Nextcloud Signing status

Unknown, since update failed.

Nextcloud Logs

{"reqId":"X4-zj71PUKYWVIjtqdq1jwAAABM","level":2,"time":"2020-10-21T08:38:39+00:00","remoteAddr":"2001:16b8:a5bc:8900:b52:3760:5886:a2bb","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0","version":""}
{"reqId":"X4-zj71PUKYWVIjtqdq1jwAAABM","level":2,"time":"2020-10-21T08:38:39+00:00","remoteAddr":"2001:16b8:a5bc:8900:b52:3760:5886:a2bb","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0","version":""}
{"reqId":"X4-zj71PUKYWVIjtqdq1jwAAABM","level":3,"time":"2020-10-21T08:38:39+00:00","remoteAddr":"2001:16b8:a5bc:8900:b52:3760:5886:a2bb","user":"--","app":"jsresourceloader","method":"GET","url":"/","message":"Could not find resource js/setup.js to load","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0","version":""}
{"reqId":"X4-zxNs8mqRDYzxmNMp4BwAAACg","level":2,"time":"2020-10-21T08:39:32+00:00","remoteAddr":"2001:16b8:a5bc:8900:b52:3760:5886:a2bb","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0","version":""}
{"reqId":"X4-zxNs8mqRDYzxmNMp4BwAAACg","level":2,"time":"2020-10-21T08:39:32+00:00","remoteAddr":"2001:16b8:a5bc:8900:b52:3760:5886:a2bb","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0","version":""}

Additional info

No response

fsch2 commented 4 months ago

I was able to solve this in the following way:

  1. Connect to database
  2. Run DROP INDEX rd_wopi_token_idx ON nc_9337_richdocuments_wopi;
  3. Disconnect
  4. Then upgrade ./occ upgrade
  5. And add missing indices: ./occ db:add-missing-indices

See https://github.com/nextcloud/server/issues/41253 for details.