Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when updating to 30.0.2: Foreign key constraint is incorrectly formed #3778

Open
6 of 12 tasks
m8ichael opened this issue Nov 16, 2024 · 7 comments
Open
6 of 12 tasks
Labels

Comments

@m8ichael
Copy link

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • I agree to follow Nextcloud's Code of Conduct.

What went wrong, what did you observe?

When I updated to NC 30.0.2, I got a problem updating polls.

  • ERROR: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1005 Can't create table nextcloud.oc_polls_comments (errno: 150 "Foreign key constraint is incorrectly formed")

I first tried to disable polls, delete the tables oc_polls_*, restore them from backup an re-enabled polls, but the problem persists.

What did you expect, how polls should behave instead?

No error message when the upgrade-command is executed

What steps does it need to replay this bug?

  1. The problem appears when I do the command: occ maintenance:repair --include-expensive

Installation method

Installed/updated from the appstore (Apps section of your site)

Installation type

Updated from previous major version (i.e. 3.x.x to 4.x.x)

Affected polls version

7.2.4

Which browser did you use, when experiencing the bug?

  • Firefox
  • Chrome
  • Chromium/Chromium based (i.e. Edge)
  • Safari
  • Other/Don't know

Other browser

No response

Add your browser log here

Additional client environment information

No response

NC version

Nextcloud 30

Other Nextcloud version

No response

PHP engine version

PHP 8.3

Other PHP version

No response

Database engine

MariaDB

Database Engine version or other Database

10.5.8

Which user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other/Don't know

Add your nextcloud server log here

no logs for polls found

Additional environment informations

No response

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud.alpenverein-hannover.de"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "30.0.2.2",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "default_language": "de",
        "default_locale": "de_DE",
        "installed": true,
        "remember_login_cookie_lifetime": 1296000,
        "session_lifetime": 86400,
        "session_keepalive": true,
        "skeletondirectory": "",
        "knowledgebaseenabled": false,
        "lost_password_link": "disabled",
        "ldapIgnoreNamingRules": false,
        "ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_smtpauthtype": "LOGIN",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "auth.bruteforce.protection.enabled": true,
        "maintenance": false,
        "updater.release.channel": "stable",
        "maintenance_window_start": 1,
        "theme": "",
        "loglevel": 2,
        "forcessl": true,
        "forceSSLforSubdomains": true,
        "trashbin_retention_obligation": "7, 20",
        "has_internet_connection": true,
        "check_for_working_webdav": true,
        "check_for_working_wellknown_setup": true,
        "check_for_working_htaccess": true,
        "cron_log": true,
        "logtimezone": "Europe\/Berlin",
        "logdateformat": "F d, Y H:i:s",
        "ldapUserCleanupInterval": 51,
        "filelocking.enabled": "true",
        "mail_smtpsecure": "ssl",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url": "https:\/\/cloud.alpenverein-hannover.de",
        "share_folder": "\/Mit mir geteilt",
        "app_install_overwrite": [
            "calendar",
            "circles",
            "groupfolders",
            "ocr",
            "impersonate",
            "bruteforcesettings",
            "twofactor_gateway",
            "issuetemplate",
            "checksum_api"
        ],
        "twofactor_enforced": "true",
        "twofactor_enforced_groups": [
            "AdminUser2F"
        ],
        "twofactor_enforced_excluded_groups": [],
        "mysql.utf8mb4": true,
        "default_phone_region": "DE",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "timeout": 0
        },
        "preview_max_x": 1024,
        "preview_max_y": 768,
        "preview_max_scale_factor": 1,
        "activity_expire_days": 30,
        "allow_local_remote_servers": true
    }
}

List of activated Apps

Enabled:
  - activity: 3.0.0
  - admin_audit: 1.20.0
  - announcementcenter: 7.0.1
  - app_api: 4.0.0
  - bruteforcesettings: 3.0.0
  - calendar: 5.0.1
  - calendar_resource_management: 0.8.0
  - checksum: 1.2.5
  - circles: 30.0.0
  - cloud_federation_api: 1.13.0
  - comments: 1.20.1
  - contacts: 6.1.1
  - dav: 1.31.1
  - deck: 1.14.2
  - drawio: 3.0.3
  - external: 5.5.2
  - federatedfilesharing: 1.20.0
  - federation: 1.20.0
  - files: 2.2.0
  - files_downloadactivity: 1.17.0
  - files_downloadlimit: 3.0.0
  - files_external: 1.22.0
  - files_reminders: 1.3.0
  - files_sharing: 1.22.0
  - files_trashbin: 1.20.1
  - files_versions: 1.23.0
  - groupfolders: 18.0.5
  - impersonate: 1.17.0
  - logreader: 3.0.0
  - lookup_server_connector: 1.18.0
  - notifications: 3.0.0
  - oauth2: 1.18.1
  - onlyoffice: 9.5.0
  - ownershiptransfer: 1.0.1
  - password_policy: 2.0.0
  - passwords: 2024.11.20
  - polls: 7.2.4
  - privacy: 2.0.0
  - provisioning_api: 1.20.0
  - quota_warning: 1.20.0
  - recommendations: 3.0.0
  - related_resources: 1.5.0
  - serverinfo: 2.0.0
  - settings: 1.13.0
  - sharebymail: 1.20.0
  - text: 4.1.0
  - theming: 2.5.0
  - theming_customcss: 1.17.0
  - twofactor_backupcodes: 1.19.0
  - twofactor_totp: 12.0.0-dev
  - updatenotification: 1.20.0
  - user_ldap: 1.21.0
  - viewer: 3.0.0
  - webhook_listeners: 1.1.0-dev
  - workflowengine: 2.12.0
Disabled:
  - apporder: 0.15.0 (installed 0.15.0)
  - contactsinteraction: 1.11.0 (installed 1.2.0)
  - dashboard: 7.10.0 (installed 7.0.0)
  - encryption: 2.18.0
  - files_accesscontrol: 1.19.1 (installed 1.19.1)
  - files_automatedtagging: 1.19.0 (installed 1.19.0)
  - files_mindmap: 0.0.30 (installed 0.0.30)
  - files_pdfviewer: 3.0.0 (installed 1.2.1)
  - files_rightclick: 0.15.1 (installed 1.6.0)
  - firstrunwizard: 3.0.0 (installed 2.1)
  - geoblocker: 0.5.15 (installed 0.5.15)
  - integration_zammad: 3.0.1 (installed 3.0.1)
  - issuetemplate: 0.7.0 (installed 0.7.0)
  - mail: 3.7.9 (installed 3.7.9)
  - nextcloud_announcements: 2.0.0 (installed 1.10.0)
  - occweb: 0.2.0 (installed 0.2.0)
  - photos: 3.0.2 (installed 1.0.0)
  - spreed: 19.0.11 (installed 19.0.11)
  - support: 2.0.0 (installed 1.0.0)
  - survey_client: 2.0.0 (installed 1.3.0)
  - suspicious_login: 8.0.0
  - systemtags: 1.20.0 (installed 1.11.0)
  - tasks: 0.16.1 (installed 0.16.1)
  - terms_of_service: 4.0.0 (installed 4.0.0)
  - twofactor_nextcloud_notification: 4.0.0
  - user_status: 1.10.0 (installed 1.1.1)
  - weather_status: 1.10.0 (installed 1.1.0)

Nextcloud Signing status

No errors have been found.

Additional Information

No response

@m8ichael m8ichael added the bug label Nov 16, 2024
@dartcafe
Copy link
Collaborator

have you tried occ polls:db:rebuild?

@m8ichael
Copy link
Author

@dartcafe Yes, I tried that, but with no results. The error still exists.

@dartcafe
Copy link
Collaborator

That makes no sense.
occ polls:db:rebuild removes all indices and foreign key constraints.
After that the tables are checked and updated (or created, if not existent). So there can't exist any foreign key constraint affecting the polls tables.

Either the error message is misleading or something else exists inside the database, preventing the action. Is there any stack trace of the error?

What confuses me, is that the creation of the comments table is reported to be failing. This leads to the conclusion, that it does not exist.

An export of the table definitions could help.

@m8ichael

This comment has been minimized.

@dartcafe
Copy link
Collaborator

There is no hint inside the table structure, which may help to analyze the error.

I need more details about the error line, to get an idea, what is wrong. It seems the error does not describe a failure on creating the table but attaching the fk. There should be more information within the printed error which names the failing fk structure.

@m8ichael
Copy link
Author

OK, now I got an error, when I try to use occ polls:db:rebuild:

Step 3. Create or update tables to current shema
 - Set db structure
   Validating table oc_polls_polls
   Validating table oc_polls_options
   Validating table oc_polls_votes
   Validating table oc_polls_comments
   Validating table oc_polls_share
   Validating table oc_polls_notif
   Validating table oc_polls_log
   Validating table oc_polls_watch
   Validating table oc_polls_preferences

In DbalException.php line 54:

  An exception occurred while executing a query: SQLSTATE[42000]: Syntax erro
  r or access violation: 1075 Incorrect table definition; there can be only o
  ne auto column and it must be defined as a key


In ExceptionConverter.php line 118:

  An exception occurred while executing a query: SQLSTATE[42000]: Syntax erro
  r or access violation: 1075 Incorrect table definition; there can be only o
  ne auto column and it must be defined as a key


In Exception.php line 28:

  SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table def
  inition; there can be only one auto column and it must be defined as a key


In Connection.php line 33:

  SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table def
  inition; there can be only one auto column and it must be defined as a key

@dartcafe
Copy link
Collaborator

I have no idea, what resides inside your database, but these error messages still make no sense to me, since this seems no wide spread problem.

Please try to wipe all polls related tables and information (you can do this with occ polls:db:purge)

I recommend the following steps:

  • make a backup of our polls tables (just the rows, not the schema definition)
    • make separate backups of oc_polls_polls and the other tables
  • run occ polls:db:purge
  • run occ app:remove polls
  • install polls again
  • Important: First import your oc_polls_polls table from the backup. Other wise the fk will throw errors
  • After that, import all other tables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants