Activating Nextcloud calendar leads to mysql-error

OK, I thought you already downgraded.
You need to downgrade to nethserver-nextcloud-1.16.7-1 and then go step by step up to 1.19.7-1.

EDIT:

Don’t downgrade. Downgrading did not work for me, I got an internal server error.

EDIT2:

This method worked for me:

I updated to latest nethserver-nextcloud and followed

b) Migration scripts to latest version (experimental procedure):

from the wiki.

I red your first EDIT too late and did the downgrade. Should I now install the latest one again and then follow the migration scripts?

Yes, exactly.

yum update nethserver-nextcloud

and then follow the scripts.

The current Nextcloud version number is 23.0.8.1

After doing
occ migrations:migrate core
I get:

[root@nethserver config]# occ migrations:migrate core
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade

In MigrationService.php line 429:
                                                             
  Database error when running migration latest for app core  
                                                             

In ExceptionConverter.php line 101:
                                                                                       
  An exception occurred while executing a query: An exception occurred while executin  
  g a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away           
                                                                                       

In ExceptionConverter.php line 101:
                                                                                       
  An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006  
   MySQL server has gone away                                                          
                                                                                       

In Exception.php line 26:
                                                                   
  SQLSTATE[HY000]: General error: 2006 MySQL server has gone away  
                                                                   

In Connection.php line 82:
                                                                   
  SQLSTATE[HY000]: General error: 2006 MySQL server has gone away  
                                                                   

migrations:migrate <app> [<version>]

I hope it’s because of the calendar app and it still runs through.

To remove calendar:

occ app:remove calendar

Should I first remove the calendar and then try the migration again?

Yes, it’s worth a try.

The same errors appear again. Should I try occ upgrade, nevertheless?

If you have a backup, yes.

Update failed, unfortunately.

[root@nethserver config]# occ upgrade
Nextcloud or one of the apps require upgrade - only a limited number of commands are ava
ilable
You may use your browser or the occ upgrade command to do the upgrade
Setting log level to debug
Turned on maintenance mode
Repair error: An exception occurred while executing a query: An exception occurred while
executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away      
Repair error: Failed to connect to the database: An exception occurred in the driver: SQ
LSTATE[HY000] [2002] Connection refused                                                  
Updating database schema
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the
driver: SQLSTATE[HY000] [2002] Connection refused                                       
Update failed
Maintenance mode is kept active
Resetting log level

Hm, the same DB error. Sorry, I’m out of options for now.
Maybe restore from backup/snapshot and start again with the step by step updates?

do not recall if that error is related to this or not but make sure debug mode is enabled during execution of migration scripts

2 Likes

debug mode was enabled

Restoring config-backup from day before did not work, unfortunately.

echo '{"action":"restore-backup-config","data":"u00","InstallPackages":"enabled","SkipNetwork":"disabled","remap":{"enp4s0":"enp4s0"}}' | /usr/bin/setsid /usr/bin/sudo /usr/libexec/nethserver/api/system-backup/execute | jq

How to work around “general error: 2006 MySQL server has gone away"

The database request takes too long and therefore the MySQL server times out. It’s also possible that the server is dropping a packet that is too large. Please refer to the manual of your database for how to raise the configuration options wait_timeout and/or max_allowed_packet.

Some shared hosters are not allowing the access to these config options. For such systems Nextcloud is providing a dbdriveroptions configuration option within your config/config.php where you can pass such options to the database driver. Please refer to Configuration Parameters for an example.

Example config parameter:

'dbdriveroptions' => [
        PDO::MYSQL_ATTR_INIT_COMMAND => 'SET wait_timeout = 28800'
],
1 Like

I could change the values for wait_timeout and max_allowed_packet to their maximum:

MariaDB [(none)]> show variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout  | 50000 |
+---------------+-------+
1 row in set (0.00 sec)

MariaDB [(none)]> show variables like 'max_allowed_packet';
+--------------------+------------+
| Variable_name      | Value      |
+--------------------+------------+
| max_allowed_packet | 1073741824 |
+--------------------+------------+
1 row in set (0.00 sec)

Trying to do the update leads to the same error-messages:

Update vorbereiten
Log-Level auf "debug" gesetzt
Wartungsmodus eingeschaltet
Reparaturschritt: Repair MySQL collation
Reparaturinformation: All tables already have the correct collation -> nothing to do
Reparaturschritt: Repair SQLite autoincrement
Reparaturschritt: Copy data from accounts table when migrating from ownCloud
Reparaturfehler: An exception occurred while executing a query: An exception occurred while executing
a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
Reparaturschritt: Drop account terms table when migrating from ownCloud
Reparaturfehler: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused
Das Datenbankschema wird aktualisiert
Doctrine\DBAL\Exception: Failed to connect to the database: 
An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused

And nothing seems to change, when I try to use the migrations scripts:

In MigrationService.php line 429:
Database error when running migration latest for app core  
In ExceptionConverter.php line 101:
An exception occurred while executing a query: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away           
In ExceptionConverter.php line 101:                                                                                 
An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away                                                                          
In Exception.php line 26:                                                                
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away  
In Connection.php line 82:                                                                   
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

You can check if nextcloud mysql user has access to the database.

Can you share the settings:

grep 'db /usr/share/nextcloud/config/config.php |grep -v dbpass
/opt/rh/rh-mariadb105/root/bin/mysql --socket="/var/run/rh-mariadb105-mariadb/nextcloud-mysql.sock" -e 'SELECT user FROM mysql.user'
mysql --socket="/var/run/rh-mariadb105-mariadb/nextcloud-mysql.sock" -e "SHOW GRANTS FOR 'nextcloud'@'localhost'"

Check if ‘dbpassword’ value in config.php is the same as the one from /var/lib/nethserver/secrets/nextcloud

Thanks for the suggested commands!

  1. The value for 'dbpassword' in config.php is the same as the one from /var/lib/nethserver/secrets/nextcloud.
  2. nextcloud is in the list of mysql-user:
/opt/rh/rh-mariadb105/root/bin/mysql --socket=
"/var/run/rh-mariadb105-mariadb/nextcloud-mysql.sock" -e 'SELECT user FROM mysql.user'
+-------------+
| User        |
+-------------+
| mariadb.sys |
| mysql       |
| nextcloud   |
| root        |
+-------------+
  1. Granted accesses are the following. I just hided the password.
mysql --socket="/var/run/rh-mariadb105-mariadb/nextcloud-mysql.sock" -e "SHOW GRANTS FOR 'nextcloud'@'localhost'"
+------------------------------------------------------------------------------------------------------------------+
| Grants for nextcloud@localhost                                                                                   |
+------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `nextcloud`@`localhost` IDENTIFIED BY PASSWORD '*A****************1' |
| GRANT ALL PRIVILEGES ON `nextcloud`.* TO `nextcloud`@`localhost`

So everything seems to be right here, doesn’t it?