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

[Bug]: Unable to enable user_ldap app - PostgreSQL error: index "primary" does not exist #36864

Open
5 of 9 tasks
skid9000 opened this issue Feb 25, 2023 · 21 comments
Open
5 of 9 tasks
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 25-feedback 27-feedback bug feature: apps management feature: ldap needs review Needs review to determine if still applicable

Comments

@skid9000
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).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

I'm unable to enable the user_ldap app, resulting with the following error :
An exception occurred while executing a query: SQLSTATE[42704]: Undefined object: 7 ERROR: index "primary" does not exist

Steps to reproduce

  1. ./occ app:enable user_ldap
  2. Get the error

Expected behavior

The app should enable.

Installation method

Community Manual installation with Archive

Operating system

Other

PHP engine version

PHP 8.1

Web server

Nginx

Database engine version

PostgreSQL

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

None

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

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

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "25.0.4.1",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "maintenance": false,
        "theme": "",
        "loglevel": 2,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "debug": "false",
        "updater.release.channel": "stable",
        "app_install_overwrite": [
            "ocsms",
            "sensorlogger",
            "contacts",
            "unsplash"
        ],
        "encryption.key_storage_migrated": false,
        "default_phone_region": "FR",
        "filesystem_check_changes": 1,
        "mail_smtpmode": "smtp",
        "mail_smtpauthtype": "PLAIN",
        "mail_sendmailmode": "smtp",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpsecure": "ssl",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "updater.secret": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

Enabled:
  - activity: 2.17.0
  - admin_audit: 1.15.0
  - audioplayer: 3.3.1
  - calendar: 4.2.4
  - circles: 25.0.0
  - cloud_federation_api: 1.8.0
  - comments: 1.15.0
  - contacts: 5.1.0
  - contactsinteraction: 1.6.0
  - dashboard: 7.5.0
  - dav: 1.24.0
  - encryption: 2.13.0
  - federatedfilesharing: 1.15.0
  - files: 1.20.1
  - files_external: 1.17.0
  - files_pdfviewer: 2.6.0
  - files_rightclick: 1.4.0
  - files_sharing: 1.17.0
  - files_trashbin: 1.15.0
  - logreader: 2.10.0
  - lookup_server_connector: 1.13.0
  - maps: 0.2.4
  - nextcloud_announcements: 1.14.0
  - notes: 4.6.0
  - notifications: 2.13.1
  - oauth2: 1.13.0
  - ocsms: 2.2.0
  - password_policy: 1.15.0
  - photos: 2.0.1
  - privacy: 1.9.0
  - provisioning_api: 1.15.0
  - recommendations: 1.4.0
  - related_resources: 1.0.4
  - serverinfo: 1.15.0
  - settings: 1.7.0
  - support: 1.8.0
  - systemtags: 1.15.0
  - text: 3.6.0
  - theming: 2.0.1
  - twofactor_backupcodes: 1.14.0
  - twofactor_totp: 7.0.0
  - updatenotification: 1.15.0
  - user_status: 1.5.0
  - viewer: 1.9.0
  - weather_status: 1.5.0
  - workflowengine: 2.7.0
Disabled:
  - bruteforcesettings: 2.3.0
  - federation: 1.3.0
  - files_versions: 1.16.0
  - firstrunwizard: 2.2.1
  - gpxedit: 0.0.14
  - gpxpod: 5.0.4
  - keeweb: 0.6.10
  - sharebymail: 1.3.0
  - survey_client: 1.1.0
  - suspicious_login
  - user_ldap

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

{"reqId":"HnUMISJJgQ7P51ipL9jy","level":3,"time":"2023-02-25T16:19:22+00:00","remoteAddr":"REDACTED","user":"skid","app":"settings","method":"POST","url":"/settings/apps/enable","message":"could not enable apps","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0","version":"25.0.4.1","exception":{"Exception":"Doctrine\\DBAL\\Exception\\DriverException","Message":"An exception occurred while executing a query: SQLSTATE[42704]: Undefined object: 7 ERROR:  index \"primary\" does not exist","Code":7,"Trace":[{"file":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Connection.php","line":1780,"function":"convert","class":"Doctrine\\DBAL\\Driver\\API\\PostgreSQL\\ExceptionConverter","type":"->"},{"file":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Connection.php","line":1719,"function":"handleDriverException","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Connection.php","line":1067,"function":"convertExceptionDuringQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/Connection.php","line":261,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Connection.php","line":1809,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/Migrator.php","line":162,"function":"query","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/Migrator.php","line":69,"function":"applySchema","class":"OC\\DB\\Migrator","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/Connection.php","line":582,"function":"migrate","class":"OC\\DB\\Migrator","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/MigrationService.php","line":454,"function":"migrateToSchema","class":"OC\\DB\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/MigrationService.php","line":408,"function":"migrateSchemaOnly","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/Installer.php","line":153,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/usr/home/nextcloud/live/apps/settings/lib/Controller/AppSettingsController.php","line":451,"function":"installApp","class":"OC\\Installer","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/AppFramework/Http/Dispatcher.php","line":225,"function":"enableApps","class":"OCA\\Settings\\Controller\\AppSettingsController","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/AppFramework/Http/Dispatcher.php","line":133,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/AppFramework/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/Route/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/usr/home/nextcloud/live/lib/base.php","line":1047,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/usr/home/nextcloud/live/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php","Line":83,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDO\\Exception","Message":"SQLSTATE[42704]: Undefined object: 7 ERROR:  index \"primary\" does not exist","Code":7,"Trace":[{"file":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","line":87,"function":"new","class":"Doctrine\\DBAL\\Driver\\PDO\\Exception","type":"::"},{"file":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Connection.php","line":1062,"function":"query","class":"Doctrine\\DBAL\\Driver\\PDO\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/Connection.php","line":261,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Connection.php","line":1809,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/Migrator.php","line":162,"function":"query","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/Migrator.php","line":69,"function":"applySchema","class":"OC\\DB\\Migrator","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/Connection.php","line":582,"function":"migrate","class":"OC\\DB\\Migrator","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/MigrationService.php","line":454,"function":"migrateToSchema","class":"OC\\DB\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/MigrationService.php","line":408,"function":"migrateSchemaOnly","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/Installer.php","line":153,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/usr/home/nextcloud/live/apps/settings/lib/Controller/AppSettingsController.php","line":451,"function":"installApp","class":"OC\\Installer","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/AppFramework/Http/Dispatcher.php","line":225,"function":"enableApps","class":"OCA\\Settings\\Controller\\AppSettingsController","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/AppFramework/Http/Dispatcher.php","line":133,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/AppFramework/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/Route/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/usr/home/nextcloud/live/lib/base.php","line":1047,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/usr/home/nextcloud/live/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php","Line":26,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[42704]: Undefined object: 7 ERROR:  index \"primary\" does not exist","Code":"42704","Trace":[{"file":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","line":82,"function":"query","class":"PDO","type":"->"},{"file":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Connection.php","line":1062,"function":"query","class":"Doctrine\\DBAL\\Driver\\PDO\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/Connection.php","line":261,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Connection.php","line":1809,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/Migrator.php","line":162,"function":"query","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/Migrator.php","line":69,"function":"applySchema","class":"OC\\DB\\Migrator","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/Connection.php","line":582,"function":"migrate","class":"OC\\DB\\Migrator","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/MigrationService.php","line":454,"function":"migrateToSchema","class":"OC\\DB\\Connection","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/DB/MigrationService.php","line":408,"function":"migrateSchemaOnly","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/Installer.php","line":153,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/usr/home/nextcloud/live/apps/settings/lib/Controller/AppSettingsController.php","line":451,"function":"installApp","class":"OC\\Installer","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/AppFramework/Http/Dispatcher.php","line":225,"function":"enableApps","class":"OCA\\Settings\\Controller\\AppSettingsController","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/AppFramework/Http/Dispatcher.php","line":133,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/AppFramework/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/usr/home/nextcloud/live/lib/private/Route/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/usr/home/nextcloud/live/lib/base.php","line":1047,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/usr/home/nextcloud/live/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/usr/home/nextcloud/live/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","Line":82}},"message":"could not enable apps","exception":[],"CustomMessage":"could not enable apps"},"id":"63fa44db94226"}

Additional info

No response

@skid9000 skid9000 added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Feb 25, 2023
@solracsf
Copy link
Member

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

@solracsf solracsf changed the title [Bug]: Unable to enable user_ldap app. [Bug]: Unable to enable user_ldap app - PostgreSQL error: index "primary" does not exist Feb 25, 2023
@skid9000
Copy link
Author

I never tried to enable user_ldap before so i can't tell if this bug existed in a previous major update, sorry :/

@solracsf
Copy link
Member

Ok but this isn't a fresh install, right?
Just to understand if this is a migration error or a codebase error.

@skid9000
Copy link
Author

Yes, this isn't a fresh install.

@solracsf
Copy link
Member

Thanks. Just to complete the report, please execute :

./occ db:add-missing-indices
./occ db:add-missing-columns
./occ db:add-missing-primary-keys

And report back please if this helps.

@skid9000
Copy link
Author

Thanks, but it dosen't seem to work :/

 nextcloud@nextcloud  ~/live  ./occ db:add-missing-indices
./occ db:add-missing-columns
./occ db:add-missing-primary-keys

Check indices of the share table.
Check indices of the filecache table.
Check indices of the twofactor_providers table.
Check indices of the login_flow_v2 table.
Check indices of the whats_new table.
Check indices of the cards table.
Check indices of the cards_properties table.
Check indices of the calendarobjects_props table.
Check indices of the schedulingobjects table.
Check indices of the oc_properties table.
Check indices of the oc_jobs table.
Check indices of the oc_direct_edit table.
Check indices of the oc_preferences table.
Check indices of the oc_mounts table.
Done.
Check columns of the comments table.
Done.
Check primary keys.
Done.
 nextcloud@nextcloud  ~/live  ./occ app:enable user_ldap  
An exception occurred while executing a query: SQLSTATE[42704]: Undefined object: 7 ERROR:  index "primary" does not exist

@Nihlus
Copy link

Nihlus commented Mar 13, 2023

I have the same issue, also on an existing install. This is an old instance that I've been upgrading ever since the owncloud days, so it's been through a fair amount of migrations and updates. I tried running the various db:add-missing commands to no effect.

@joshtrichards

This comment was marked as resolved.

@Nihlus
Copy link

Nihlus commented Sep 9, 2023

Sorry about the late reply, busy days. This is the output I get.

jarl@nextcloud1:/var/www/nextcloud$ sudo -u www-data NC_debug=1 ./occ migrations:status user_ldap

In MigrationService.php line 498:
                                                                                     
  Migration step 'OCA\User_LDAP\Migration\Version1010Date20200630192842' is unknown  
                                                                                     

migrations:status <app>

I can enable other apps just fine.

I think the most unusual thing about this instance is that it's been continuously upgraded, migrated, and moved all the way from the ownCloud days, though I can't recall if I've wiped and recreated the database at any point during these years. I believe I did so when transitioning from ownCloud to Nextcloud, but I don't know for sure.

@joshtrichards

This comment was marked as resolved.

@skid9000

This comment was marked as resolved.

@joshtrichards

This comment was marked as resolved.

@skid9000

This comment was marked as resolved.

@Nihlus

This comment was marked as resolved.

@Nihlus

This comment was marked as resolved.

@skid9000

This comment was marked as resolved.

@joshtrichards
Copy link
Member

Unfortunately, in hindsight, you're both getting the Migration step ... is unknown error simply due to the user_ldap app never fully getting enabled (due to the original An exception occurred while executing a query: SQLSTATE[42704]: Undefined object: 7 ERROR: index "primary" does not exist error). So, unfortunately, the inability to check the db migration status is a red herring.

I think I'm getting closer to the real culprit in any case: doctrine/dbal#2925 and is similar to #30539. It was addressed in #30568 though.

I'm currently stumped regarding why you two are impacted still.

@Nihlus Are you running PostgreSQL as well?

@skid9000
Copy link
Author

skid9000 commented Sep 10, 2023

Since i made this issue i'm now running PostgreSQL 15.4 and NC 27.0.2 (w/php 8.2), i don't know if that information could help you out.

(Back then i was running PostgreSQL 14 and NC 25.0.4.1 (w/php 8.1) iirc)

@Nihlus
Copy link

Nihlus commented Sep 10, 2023

@joshtrichards Yep, running Postgres 14.7-1.pgdg110+1. My PHP version is 7.4.

@joshtrichards joshtrichards added the needs review Needs review to determine if still applicable label Sep 6, 2024
@joshtrichards
Copy link
Member

It's odd that there is an empty version string for your user_ldap app installation. It should contain what is in user_ldap/appinfo/info.xml:

Disabled:
  - bruteforcesettings: 2.3.0
  - federation: 1.3.0
  - files_versions: 1.16.0
  - firstrunwizard: 2.2.1
  - gpxedit: 0.0.14
  - gpxpod: 5.0.4
  - keeweb: 0.6.10
  - sharebymail: 1.3.0
  - survey_client: 1.1.0
  - suspicious_login
  - user_ldap

Any chance you at one point ran an Release Candidate (RC) [particularly 23.0.1RC1, 22.2.4RC1] against this installation?

@skid9000
Copy link
Author

Any chance you at one point ran an Release Candidate (RC) [particularly 23.0.1RC1, 22.2.4RC1] against this installation?

I don't think so, i always stayed on stable branch and updated through the nextcloud updater, so my instance should never have seen any RC version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 25-feedback 27-feedback bug feature: apps management feature: ldap needs review Needs review to determine if still applicable
Projects
None yet
Development

No branches or pull requests

4 participants