circles icon indicating copy to clipboard operation
circles copied to clipboard

[Bug]: Database error when running migration latest for app circles

Open arbythree opened this issue 3 years ago • 3 comments

⚠️ This issue respects the following points: ⚠️

  • [X] This is a bug, not a question or a configuration/webserver/proxy issue.
  • [X] This issue is not already reported on Github (I've searched it).
  • [X] Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • [X] I agree to follow Nextcloud's Code of Conduct.

Bug description

Upgrade to 23.0.4 fails on "Circles" app

Steps to reproduce

  1. Initiate web-based upgrade to 23.0.4

Expected behavior

Upgrade completes successfully

Installation method

Web installer on a VPS or web space

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.0

Web server

Apache (supported)

Database engine version

MySQL

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

Updated from a minor version (ex. 22.2.3 to 22.2.4)

Are you using the Nextcloud Server Encryption module?

No response

What user-backends are you using?

  • [ ] Default user-backend (database)
  • [ ] LDAP/ Active Directory
  • [ ] SSO - SAML
  • [ ] Other

Configuration report

{
    "system": {
        "default_phone_region": "US",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "f.bdly.org",
            "fprime.bdly.org"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "23.0.3.2",
        "overwrite.cli.url": "https:\/\/f.bdly.org",
        "htaccess.RewriteBase": "\/",
        "dbdriveroptions": {
            "1009": "\/etc\/ssl\/certs\/nextcloud-mysql.crt",
            "1014": true
        },
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "installed": true,
        "mail_smtpmode": "smtp",
        "mail_smtpsecure": "tls",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "theme": "",
        "loglevel": 0,
        "updater.secret": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

Enabled:
  - accessibility: 1.9.0
  - activity: 2.15.0
  - bruteforcesettings: 2.3.0
  - calendar: 3.2.2
  - circles: 23.1.0
  - cloud_federation_api: 1.6.0
  - comments: 1.13.0
  - contacts: 4.1.0
  - contactsinteraction: 1.4.0
  - dashboard: 7.3.0
  - dav: 1.21.0
  - federatedfilesharing: 1.13.0
  - federation: 1.13.0
  - files: 1.18.0
  - files_fulltextsearch: 23.0.0
  - files_pdfviewer: 2.4.0
  - files_rightclick: 1.2.0
  - files_sharing: 1.15.0
  - files_trashbin: 1.13.0
  - files_versions: 1.16.0
  - files_videoplayer: 1.12.0
  - firstrunwizard: 2.12.0
  - fulltextsearch: 23.0.0
  - fulltextsearch_elasticsearch: 23.0.0
  - logreader: 2.8.0
  - lookup_server_connector: 1.11.0
  - mail: 1.11.7
  - nextcloud_announcements: 1.12.0
  - notifications: 2.11.1
  - oauth2: 1.11.0
  - password_policy: 1.13.0
  - photos: 1.5.0
  - privacy: 1.7.0
  - provisioning_api: 1.13.0
  - recommendations: 1.2.0
  - richdocuments: 5.0.3
  - serverinfo: 1.13.0
  - settings: 1.5.0
  - sharebymail: 1.13.0
  - spreed: 13.0.4
  - support: 1.6.0
  - survey_client: 1.11.0
  - systemtags: 1.13.0
  - text: 3.4.1
  - theming: 1.14.0
  - twofactor_backupcodes: 1.12.0
  - twofactor_totp: 6.2.0
  - updatenotification: 1.13.0
  - user_status: 1.3.1
  - viewer: 1.7.0
  - weather_status: 1.3.0
  - workflowengine: 2.5.0
Disabled:
  - admin_audit
  - encryption
  - files_external
  - user_ldap

Nextcloud Signing status

No response

Nextcloud Logs

qsx8agM%3D%3AVkwlcoPED10dz6kxUKuPq5kU2cPox1FOICUU4Y8mO2Q%3D","message":"Database error when running migration latest for app circles","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0","version":"23.0.3.2","exception":{"Exception":"Exception","Message":"Database error when running migration latest for app circles","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/legacy/OC_App.php","line":1021,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":353,"function":"updateApp","class":"OC_App","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":265,"function":"doAppUpgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":133,"function":"doUpgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/nextcloud/core/ajax/update.php","line":194,"function":"upgrade","class":"OC\\Updater","type":"->"}],"File":"/var/www/nextcloud/lib/private/DB/MigrationService.php","Line":429,"Previous":{"Exception":"Doctrine\\DBAL\\Exception\\DriverException","Message":"An exception occurred while executing a query: SQLSTATE[HY000]: General error: 3750 Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting.","Code":3750,"Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1780,"function":"convert","class":"Doctrine\\DBAL\\Driver\\API\\MySQL\\ExceptionConverter","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1719,"function":"handleDriverException","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1067,"function":"convertExceptionDuringQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":237,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1809,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Migrator.php","line":175,"function":"query","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Migrator.php","line":76,"function":"applySchema","class":"OC\\DB\\Migrator","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":546,"function":"migrate","class":"OC\\DB\\Migrator","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/MigrationService.php","line":540,"function":"migrateToSchema","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/MigrationService.php","line":425,"function":"executeStep","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_App.php","line":1021,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":353,"function":"updateApp","class":"OC_App","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":265,"function":"doAppUpgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":133,"function":"doUpgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/nextcloud/core/ajax/update.php","line":194,"function":"upgrade","class":"OC\\Updater","type":"->"}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php","Line":114,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDO\\Exception","Message":"SQLSTATE[HY000]: General error: 3750 Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting.","Code":3750,"Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","line":87,"function":"new","class":"Doctrine\\DBAL\\Driver\\PDO\\Exception","type":"::"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1062,"function":"query","class":"Doctrine\\DBAL\\Driver\\PDO\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":237,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1809,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Migrator.php","line":175,"function":"query","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Migrator.php","line":76,"function":"applySchema","class":"OC\\DB\\Migrator","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":546,"function":"migrate","class":"OC\\DB\\Migrator","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/MigrationService.php","line":540,"function":"migrateToSchema","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/MigrationService.php","line":425,"function":"executeStep","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_App.php","line":1021,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":353,"function":"updateApp","class":"OC_App","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":265,"function":"doAppUpgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":133,"function":"doUpgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/nextcloud/core/ajax/update.php","line":194,"function":"upgrade","class":"OC\\Updater","type":"->"}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php","Line":26,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[HY000]: General error: 3750 Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting.","Code":"HY000","Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","line":82,"function":"query","class":"PDO","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1062,"function":"query","class":"Doctrine\\DBAL\\Driver\\PDO\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":237,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1809,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Migrator.php","line":175,"function":"query","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Migrator.php","line":76,"function":"applySchema","class":"OC\\DB\\Migrator","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":546,"function":"migrate","class":"OC\\DB\\Migrator","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/MigrationService.php","line":540,"function":"migrateToSchema","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/MigrationService.php","line":425,"function":"executeStep","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_App.php","line":1021,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":353,"function":"updateApp","class":"OC_App","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":265,"function":"doAppUpgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":133,"function":"doUpgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/nextcloud/core/ajax/update.php","line":194,"function":"upgrade","class":"OC\\Updater","type":"->"}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","Line":82}}},"CustomMessage":"Database error when running migration latest for app circles"}}

Additional info

Pasting what I believe to be the relevant portion of nextcloud.log. Looks like a table needs a primary key?

arbythree avatar Apr 23 '22 13:04 arbythree

Did you try occ db:add-missing-primary-keysas mentioned in official documentation?

felixgonsug avatar Apr 26 '22 00:04 felixgonsug

I am also encountering this issue, I just upgraded my Docker image to the latest available. Running db:add-missing-primary-keys does not fix the issue for me; for anyone else running into this that needs to get their instance back up and running, I instead had to disable the circles app temporarily, and turn off maint mode:

occ app:disable circles
occ upgrade
occ maintenance:mode --off
# restarted the next cloud app server as well

I was able to download full error logs, about 80mb worth, but I am short on time so I've just pasted the quickest and most relevant log I could find quickly.

{..."\\OC\\Updater::failure: Exception: Database error when running migration latest for app circles","userAgent":"redacted","version":"23.0.3.2","id":"redacted"}

The nextcloud version according to the web UI is now 23.0.4. Attempts to re-enable the circles app post-upgrade are failing with the same error. Could there be an issue with the db migration?

cmcode-dev avatar Apr 29 '22 03:04 cmcode-dev

I ended up finding the migration file, commenting out the guts of it, and finishing the upgrade. I then disabled the Circles app as I'm not using it. Sub-optimal but got the instance back up.

arbythree avatar Apr 29 '22 12:04 arbythree