Nextcloud and Roundcube gone after failed upgrade

Hardware: VPS
System Debian Stretch stable
YunoHost version: (stable)
I have access to my server : Through SSH
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

Description of my issue

Yesterday I upgraded first my YNH to the latest stable version on the command line and then all my outdated apps via the web interface. This worked fine apart from Roundcube and Nextcloud, which decided to disappear afterwards :smiley:


Tried to upgrade from 13.0.6 to 14.0.0. According to the logs, the upgrade errored with SQLSTATE[HY000]: General error: 2006 MySQL server has gone away.
Afterwards the app is deleted and the backup_restore fails with
ERROR 1007 (HY000) at line 1: Can't create database 'nextcloud'; database exists.
Here the full log:

I read that maybe the max_allowed_packet could cause this issue. So I increased the maximal packet size in the mysql config file like this just now:


However I am not able to re-install the app, as the ‘db already exists’. I made a backup of the NC data directory, should I manually drop the Nextcloud db and reinstall?


Tried to upgrade from 1.3.6 to 1.3.8, but that failed miserably. First error seems to be related to the PHP dep manager composer:
The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly then it cannot connect to the db anymore ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111 "Connection refused"). Full logs available here:

Are these two issues related? They both use MariaDB, but so does Baikal, which I upgraded just fine. Thank you for any hints

Well I guess yes … Though the db should have been deleted during the deletion of the app … Wondering why that did not happen :confused: In case you find the log of the deletion of nextcloud (in Tools > Logs, or with yunohost tools list and yunohost tools display [the_log_id])

Uhyea that’s like the 3rd~4th time I see this error these day, hopefully a fix is on the way in the package itself…

Well uh can you check that mysql service is up and running ? :confused:

I found the problem. Two tables (oc_accounts and oc_admin_sections) in the nextcloud mysql database are corrupted (Table doesn't exist in engine), and cause mariadb to restart on any interactions with the db. Hence the ‘Server has gone away’ and ‘Connection refused’ errors every time I try to do something. Roundcube db seems to be okay.
I tried dropping the nextcloud db manually but this only gives me

InnoDB: Error: trying to load index PRIMARY for table nextcloud/oc_accounts
InnoDB: Index is corrupt but forcing load into data dictionary

and causes the mariadb server to restart instantly. For the moment I’m stuck with the broken db. Will try to ask over at mysql forums on how to recover from that. Thanks Aleks!

Fixed it finally. My issue was a corrupted ibdata1 file (wrong permissions!!), much like in this thread [solved] MySQL service issue - corrupted ibdata1 file

Unfortunately I couldn’t recover from it, so I dumped the dbs that were still intact and recreated mysql like this:

dump dbs, including the mysql db as it contains users
mysqldump mysql > mysqldump.sql
if it works for you, you can use this one:
mysqldump --all-databases > all-dump.sql

stop mysql because we are going to recreate folders
service mysql stop
cp -a /var/lib/mysql/ /var/lib/mysql.orig
rm -rf /var/lib/mysql

initialise new db
mysql_install_db --user=mysql
restart it then restore stuff
service mysql restart
mysql -p mysql < mysqldump.sql

With a new install, the root password will not be set. However YNH initially set one. It can be found under cat /etc/yunohost/mysql

Change mysql root pw like this
mysql -u root
use mysql
SET PASSWORD FOR root@'localhost'= PASSWORD('THE_PW');
flush privileges;

Restart mysql one last time. I was then able to reinstall Nextcloud and Roundcube. Baikal worked using the restored db.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.