Bug with Updating Cookbook App and Database Tables

Nextcloud version (eg, 29.0.5): 29.0.3
Operating system and version (eg, Ubuntu 24.04): Alpine 3.20
Apache or nginx version (eg, Apache 2.4.25): NGINX 1.26.1
PHP version (eg, 8.3): 8.3.8

The issue you are facing:
I’m attempting to update the “cookbook” app, but when I do I get this error:
An error occurred during the request. Unable to proceed. Database error when running migration 000000Date20190910223344 for app cookbook The table with name "nextcloud.oc_cookbook_names" already exists.

Perhaps this failed ona previous update or uninstall in same way and left cruft in the database that didn’t get cleaned up?

Is this the first time you’ve seen this error? (Y/N): Yes

Steps to replicate it:

  1. Click Update Apps Button
  2. Get error

The output of your Nextcloud log in Admin > Logging:

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

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'redis' => 
  array (
    'host' => 'redis-nextcloud',
    'port' => 6379,
    'password' => 'REDACTED',
  ),
  'trashbin_retention_obligation' => 'auto, 30',
  'datadirectory' => '/data',
  'instanceid' => 'oce7nhhwrxtg',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' => 
  array (
    0 => 'REDACTED',
    1 => 'REDACTED',
  ),
  'dbtype' => 'mysql',
  'version' => '29.0.3.4',
  'overwrite.cli.url' => 'REDACTED',
  'dbname' => 'nextcloud',
  'dbhost' => 'mariadb',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_ncp',
  'dbpassword' => 'REDACTED',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'REDACTED',
  'mail_domain' => 'gmail.com',
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '587',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'REDACTED',
  'mail_smtppassword' => 'REDACTED',
  'default_phone_region' => 'US',
  'twofactor_enforced' => 'true',
  'twofactor_enforced_groups' => 
  array (
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
  ),
  'maintenance' => false,
  'loglevel' => 2,
  'app_install_overwrite' => 
  array (
    0 => 'news',
    1 => 'memories',
    2 => 'gpoddersync',
  ),
  'filelocking.enabled' => 'true',
  'memories.exiftool' => '/config/www/nextcloud/apps/memories/bin-ext/exiftool-amd64-musl',
  'memories.vod.path' => '/config/www/nextcloud/apps/memories/bin-ext/go-vod-amd64',
  'memories.vod.ffmpeg' => '/usr/bin/ffmpeg',
  'memories.vod.ffprobe' => '/usr/bin/ffprobe',
  'upgrade.disable-web' => true,
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\Movie',
    1 => 'OC\\Preview\\Image',
    2 => 'OC\\Preview\\HEIC',
    3 => 'OC\\Preview\\TIFF',
  ),
);

The output of your Apache/nginx/system log in /var/log/____:

2024/07/05 08:33:06 [warn] 412#412: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /config/nginx/site-confs/default.conf:13
2024/07/05 08:33:06 [warn] 412#412: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /config/nginx/site-confs/default.conf:14
2024/07/11 11:16:39 [warn] 372#372: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /config/nginx/site-confs/default.conf:13
2024/07/11 11:16:39 [warn] 372#372: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /config/nginx/site-confs/default.conf:14

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

What version are you attempting to update from? I wouldn’t expect that migration to run unless it was really old.

It’s very weird. I’m apparently up to date now? But attempting to enable it gives that table message now.

If I remove and try to download and enable it get that message too:

You manages to break your NC somehow. Please do not ask me what was that.

Nevertheless, the DB tables are currently only caching the file system content.In general, you could just drop the table oc_cookbook_names and then try to reinstall the cookbook app. In the worst case, each user might need to run a forced reload of all recipes which could take a few dozen seconds.

I hope, you get this sorted out soon. Keep me posted!

I logged into my sql database and dropped that table using:
DROP TABLE oc_cookbook_names;

Now I get this error when I try to install the app:

An error occurred during the request. Unable to proceed.
An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1005 Can't create table `nextcloud`.`oc_cookbook_names` (errno: 184 "Tablespace already exists")

Gemini suggests that there is some sort of “tablespace file” I need to find and drop? How would I find it and do that (if that is the solution)

Edit: I did find a oc_cookbook_names.ibd in
/config/databases/nextcloud

which I assume is the tablespace mentioned in the error message. I know pasting in suggestions from gemini is risky, but I have a full database backup.
It suggested I run
DROP TABLESPACE `oc_cookbook_names.ibd` ENGINE=InnoDB;

but that returns this error message:
MariaDB [nextcloud]> DROP TABLESPACE `oc_cookbook_names.ibd` ENGINE=InnoDB;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'TABLESPACE `oc_cookbook_names.ibd` ENGINE=InnoDB' at line 1

I suppose i could directly delete the .ibd file but that seems risky as hell from what I know about sql (which is next to nothing)

Hello.

I would go as following (but it involved some downtime though):

  1. Enable maintenance mode in NC
  2. Create a DB dump using mariadbdump or mysql-dump
  3. Stop the MariaDB server
  4. Copy the complete data of the server (I suppose these are in /config/databases from your writing) to a safe location
  5. Kill the idb file offending
  6. Start MariaDB again
  7. Check if you see any issues in the MariaDB logs
  8. If you can use OCC, you can try to install the app now
  9. Disable maintenance mode
  10. Cookbook should be running

If 7 fails or show errors, you can stop again and revert the backup of the files.