Nextcloud 27.0.1 OCC scripts fail with Error: Class "PDO" not found

After updating to Nextcloud 27, I got an error saying I needed to run “occ db:add-missing-indices”.

That and any other occ command are all failing with the following stack trace:

An unhandled exception has been thrown:
Error: Class "PDO" not found in /app/www/public/lib/private/DB/Connection.php:156
Stack trace:
#0 /app/www/public/lib/private/AppConfig.php(415): OC\DB\Connection->getQueryBuilder()
#1 /app/www/public/lib/private/AppConfig.php(184): OC\AppConfig->loadConfigValues()
#2 /app/www/public/lib/private/AppConfig.php(374): OC\AppConfig->getApps()
#3 /app/www/public/lib/private/legacy/OC_App.php(803): OC\AppConfig->getValues()
#4 /app/www/public/lib/private/Server.php(733): OC_App::getAppVersions()
#5 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}()
#6 /app/www/public/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#7 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#8 /app/www/public/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#9 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#10 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(193): OC\AppFramework\Utility\SimpleContainer->get()
#11 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#12 /app/www/public/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#13 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#14 /app/www/public/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#15 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#16 /app/www/public/lib/private/Server.php(1115): OC\AppFramework\Utility\SimpleContainer->get()
#17 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}()
#18 /app/www/public/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#19 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#20 /app/www/public/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#21 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#22 /app/www/public/lib/private/Server.php(2067): OC\AppFramework\Utility\SimpleContainer->get()
#23 /app/www/public/lib/private/Files/View.php(106): OC\Server->getLockingProvider()
#24 /app/www/public/lib/private/Server.php(467): OC\Files\View->__construct()
#25 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}()
#26 /app/www/public/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#27 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#28 /app/www/public/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#29 /app/www/public/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#30 /app/www/public/lib/private/Server.php(1469): OC\AppFramework\Utility\SimpleContainer->get()
#31 /app/www/public/lib/base.php(638): OC\Server->boot()
#32 /app/www/public/lib/base.php(1180): OC::init()
#33 /app/www/public/console.php(48): require_once('...')
#34 /app/www/public/occ(11): require_once('...')
#35 {main}%

Here is my docker-compose service:

  nextcloud:
    image: lscr.io/linuxserver/nextcloud:27.0.1
    container_name: nextcloud
    restart: unless-stopped
    depends_on:
      - nextcloud_db
    ports:
      - 8444:443
    volumes:
      - ${CONFIG}/cloud/nextcloud/config:/config
      - ${STORAGE}/nextcloud:/data
      - ./custom-scripts:/custom-cont-init.d:ro
      - /etc/localtime:/etc/localtime:ro
    environment:
      - TZ=${TZ}
      - PUID=${UID}
      - PGID=${GID}
      - DOCKER_MODS=linuxserver/mods:universal-package-install
      - INSTALL_PACKAGES=gcompat|libstdc++|coreutils|curl|make|composer

  nextcloud_db:
    image: mariadb
    container_name: nextcloud-mariadb
    restart: unless-stopped
    volumes:
      - ${CONFIG}/cloud/nextcloud/mariadb:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MYSQL_ROOT_PASSWORD=${CLOUD_MYSQL_ADMIN_PASSWORD}
      - MYSQL_PASSWORD=<redacted>
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

Output of docker version:

Client: Docker Engine - Community
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:51:00 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.2
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       659604f
  Built:            Thu May 25 21:51:00 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

You should try using a versioned db image instead of latest. My setup is almost identical to yours but i’m using linuxserver/mariadb:10.11.4 for my db container and upgrade to 27.0.1 went smooth. You should try to figure out which db version you had before this update and revert your container to that. Once you get that or upgrade your database as necessary to get it caught up.

I will lock the mariadb image to 11.0.2 but that’s the version it was using before the upgrade to 27.0.1, and I didn’t notice any issues with occ before. Should I dump my db, downgrade to mariadb 10 and restore the dump?

Judging from the logs you posted, it looks like your issues are around the db, so I would definitely back that up and try to get it to a working environment that’s compatible with 27.0.1

I’m having exactly the same issue after updating to 27.0.2.
Missing 4 fields in different tables and when trying to fix through the “sudo -u www-data php ./occ add-missing-indices” I’m getting the same error than @jordandrako

Any sollution for this?

It is unlikely you have the exact same issue. your issue is not doing what the readme says to do, the OPs issue is a database issue.

this is not how the readme tells you to do this.

Hi @driz

Pasting here the output of when I run “sudo -u www-data php ./occ add-missing-indices”
An unhandled exception has been thrown:

Error: Class "PDO" not found in /var/www/nextcloud/lib/private/DB/Connection.php:156
Stack trace:
#0 /var/www/nextcloud/lib/private/AppConfig.php(415): OC\DB\Connection->getQueryBuilder()
#1 /var/www/nextcloud/lib/private/AppConfig.php(184): OC\AppConfig->loadConfigValues()
#2 /var/www/nextcloud/lib/private/AppConfig.php(374): OC\AppConfig->getApps()
#3 /var/www/nextcloud/lib/private/legacy/OC_App.php(803): OC\AppConfig->getValues(false, 'installed_versi...')
#4 /var/www/nextcloud/lib/private/Server.php(733): OC_App::getAppVersions()
#5 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}(Object(OC\Server))
#6 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#7 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet('OC\\Memcache\\Fac...')
#8 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query('OC\\Memcache\\Fac...', true)
#9 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query('OC\\Memcache\\Fac...')
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(193): OC\AppFramework\Utility\SimpleContainer->get('OC\\Memcache\\Fac...')
#11 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#12 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#13 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet('OCP\\ICacheFacto...')
#14 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query('OCP\\ICacheFacto...', true)
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query('OCP\\ICacheFacto...')
#16 /var/www/nextcloud/lib/private/Server.php(1115): OC\AppFramework\Utility\SimpleContainer->get('OCP\\ICacheFacto...')
#17 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}(Object(OC\Server))
#18 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#19 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet('OCP\\Lock\\ILocki...')
#20 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query('OCP\\Lock\\ILocki...', true)
#21 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query('OCP\\Lock\\ILocki...')
#22 /var/www/nextcloud/lib/private/Server.php(2067): OC\AppFramework\Utility\SimpleContainer->get('OCP\\Lock\\ILocki...')
#23 /var/www/nextcloud/lib/private/Files/View.php(106): OC\Server->getLockingProvider()
#24 /var/www/nextcloud/lib/private/Server.php(467): OC\Files\View->__construct()
#25 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}(Object(OC\Server))
#26 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#27 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet('OC\\Files\\Node\\H...')
#28 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query('OC\\Files\\Node\\H...', true)
#29 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query('OC\\Files\\Node\\H...')
#30 /var/www/nextcloud/lib/private/Server.php(1469): OC\AppFramework\Utility\SimpleContainer->get('OC\\Files\\Node\\H...')
#31 /var/www/nextcloud/lib/base.php(638): OC\Server->boot()
#32 /var/www/nextcloud/lib/base.php(1180): OC::init()
#33 /var/www/nextcloud/console.php(48): require_once('/var/www/nextcl...')
#34 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')

If I run the suggested command “occ db: add-missing-indices” I get the following output:

bash: occ: command not found

According to my Nextcloud instance I get the following warning (sorry the portion that appear in Portuguese):

  • The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running “occ db:add-missing-indices” those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster.
    • Índice “fs_parent” em falta na tabela “oc_filecache”.
    • Índice “mounts_user_root_path_index” em falta na tabela “oc_mounts”.
    • Índice “systag_by_tagid” em falta na tabela “oc_systemtag_object_mapping”.
    • Índice “textstep_session” em falta na tabela “text_steps”.

My difference is that instead of using Docker, I’m using an LXC container. Anyway, the issue seems to be exactly the same.

couple things here

  1. did you deploy this with portainer? if yes, this is a know FEATURE of portainer to break container paths. We do not support or recommend using portainer to deploy containers
  2. we do not support or test lxc containers, though generally speaking, if you know what you’re doing, it can work.
  1. I’m not using Portainer - using an TurnKeyLinux LXC Container.

  2. Does that mean that to have support in an issue that we see happening as well with docker, I’ll need to install a new instance of NC with docker?

it means we don’t use lxc and we don’t have the problem you have, so we can’t provide any help. The OCC error looks like a path issue though.

But using the command “sudo -u www-data php ./occ add-missing-indices” it runs and should work… The issue is elsewhere.

If you’re using a turnkey lxc nextcloud container, contact the dev’s that created that.

Just because you’re seeing the same issue, the commands we give to users to fix won’t be the same for your lxc container.

closing as this conversation has run its course, we wish you the best in your endeavors.