SQLSTATE[42S02]: Base table or view not found

Hi all,
I need help to troubleshoot or directly fix an issue with my database. After upgrading my installation to the latest version (25.0.1), I got this “warning/error” after running the UPDATE process:

        Repair warning: Failed to delete folder: "13", error: An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'nxc_database1810.photos_albums' doesn't exist
        
		Repair warning: Failed to delete folder: "images", error: An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'nxc_database1810.photos_albums' doesn't exist

Is there a way to add missing tables like the occ db:add-missing-indices!? or where can I find the cross-reverence? Is this some stale config/data from a plugIn or so?

Nextcloud version (eg, 20.0.5): 25.0.1
Operating system and version (eg, Ubuntu 20.04): docker based on 8.0-apache-buster running on DSM 6.2.4
Apache or nginx version (eg, Apache 2.4.25): based on 8.0-apache-buster
PHP version (eg, 7.4): based on 8.0-apache-buster

The issue you are facing:
I am not sure if this is an actual issue or if I can ignore it. But it would be great if I can get to an “issue-free” installation, not reporting issues like this.

Is this the first time you’ve seen this error? (Y/N): Yes… I guess. I have seen it the first time at least…

Steps to replicate it:

  1. run update to next minor version

The output of your Nextcloud log in Admin > Logging:

 ## output disappears after one second.... What should I look for? I need to hack into the logs from the CLI if needed.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'forcessl' => true,
  'overwriteprotocol' => 'https',
  'instanceid' => '#########',
  'passwordsalt' => '########################',
  'secret' => '#################################################',
  'default_phone_region' => 'DE',
  'trusted_domains' => 
  array (
    0 => '172.##.##.###',
    1 => '#######.###########.de',
    2 => 'localhost',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '23.0.11.1',
  'overwrite.cli.url' => 'http://172.##.##.###:2080',
  'dbname' => 'nxc_database1810',
  'dbhost' => '172.##.##.###:3307',
  'dbport' => '',
  'dbtableprefix' => '',
  'dbuser' => '##########',
  'dbpassword' => '###############',
  'installed' => true,
  'mail_from_address' => 'nextcloud',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_domain' => '##########.de',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.#######.de',
  'mail_smtpport' => '465',
  'mail_smtpname' => '#######@###########.de',
  'mail_smtppassword' => '###########',
  'mail_smtpsecure' => 'ssl',
  'updater.secret' => '#######################################################',
  'loglevel' => 0,
  'maintenance' => false,
  'mysql.utf8mb4' => true,
  'theme' => '',
  'app_install_overwrite' => 
  array (
    0 => 'occweb',
  ),
  'has_rebuilt_cache' => true,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
);

Portainer config file:

services:
  nextcloud:
    image: mynextcloud:25.0.1.0
    container_name: nextcloud
    restart: always
    ports:
      - 2080:80
      - 2443:443
    volumes:
      - /volume1/docker/nextcloud/nxc_www-main:/var/www/html
      - /volume1/docker/nextcloud/nxc_themes:/var/www/html/themes
      - /volume1/docker/nextcloud/nxc_data:/var/www/html/data
      - /volume1/docker/nextcloud/nxc_custom_apps:/var/www/html/custom_apps
      - /volume1/docker/nextcloud/nxc_config:/var/www/html/config
    environment:
      - MYSQL_PASSWORD=###############
      - MYSQL_DATABASE=nxc_database1810
      - MYSQL_USER=##########
      - MYSQL_HOST=172.xx.xx.xxx:3307
      - NEXTCLOUD_ADMIN_PASSWORD=###############
      - NEXTCLOUD_ADMIN_USER=app########Admin

What’s going on here? Did you update from v23 to v25?

hi, I updated from 22.2.7 > 22.2.10 > 23.0.11 > 24.0.7 > 25.0.1
Did I miss a version?
Should I update this value manually?

According to the documentation this parameter is set by the system, and you shouldn’t need to change it. Maybe you do, but I think that means something went wrong during the upgrade from 23.0.11 > 24.0.7 because the config didn’t get updated.

I would not expect that config parameter to resolve the database errors.

Also I don’t see the 3rd party docker image you’re pulling on Docker Hub. Where did it come from?

I am currently migrating my Nextcloud from 24.0.7 to 25.0.1, and I have the exact same problem. Please note that I am not using docker (it is a locally installed Nextcloud) and my version string in Config.ph is “24.0.7.1”

You can find my (on going) log file there: Updating Nextcloud from 24.0.7.1 to 25.0.1Update to 25.0.1 Repair w - Pastebin.com

[Edit] My update has finally completed without any further serious issues (but it took much longer than usual). After restarting nextcloud, there was a warning about missing indices (that I fixed by running the occ command to add missing indices) and now everything seems to be running well.

Hi, the image is a local build. I need to change the second line of the dockerfile from bullseye to 8.0-apache-busterso that it can run on my old Synology system.

There was in fact a little hiccup during one of the updates. So I did it twice after setting the maintenance mode to false.

I am happy to see, that others have the same issue even that it is sad that it happens. :wink:

I’ve just updated three instances and all of them reported:

 Starting ...
 0/2 [>---------------------------]   0%Repair warning: Failed to delete folder: "6", error: An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cloud.oc_photos_albums' doesn't exist
Repair warning: Failed to delete folder: "images", error: An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cloud.oc_photos_albums' doesn't exist

The table does exist after the upgrade has completed:

mysql -e "DESCRIBE oc_photos_albums" cloud
+------------------+--------------+------+-----+---------+----------------+
| Field            | Type         | Null | Key | Default | Extra          |
+------------------+--------------+------+-----+---------+----------------+
| album_id         | bigint(20)   | NO   | PRI | NULL    | auto_increment |
| name             | varchar(255) | NO   |     | NULL    |                |
| user             | varchar(255) | NO   | MUL | NULL    |                |
| created          | bigint(20)   | NO   |     | NULL    |                |
| location         | varchar(255) | NO   |     | NULL    |                |
| last_added_photo | bigint(20)   | NO   |     | NULL    |                |
+------------------+--------------+------+-----+---------+----------------+

So I suspect this issue can simply be ignored… :person_shrugging:

is IGNORING the right thing to do? :wink:
yes, for now we can ignore it, but it should get fixed at some point, right? So the question is, who will further dig into the code and finds the bug? Or at least creates a bug-report/issue-ticket?

I believe it’s safe to ignore for now. After all, it was just trying to delete a table, perhaps one which is no longer needed. If we never had it in the first place, then maybe it’s all good.

I get only the error about oc_photo_albums table, but it may be ignored, however, inside the upgrade SQL script or PHP model, is better to add a verification about if a table exists or not.

Hi all,
I got the same error during manual upgrade from 24.0.7 to 25.0.1.
My Nextcloud is running in a straight vm with ubuntu 20.0. and php-fpm 8.0

Repair warning: Failed to delete folder: “20”, error: An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘NextCloud.oc_photos_albums’ doesn’t exist

Repair warning: Failed to delete folder: “images”, error: An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1146 Tab Done

Here below a link to the complete upgrade logs:

Right now i am ignoring the issue, because all looks to works, but i hope to haven’t further issues on the future.
Thanks a lot to anyone can helps to fix the issue or confirming it’s harmless