Tired of Database going away

Support intro

Trying to upgrade to latest version of NextCloud and my database keeps going away, I did find Database configuration — Nextcloud latest Administration Manual latest documentation which suggests editing wait_timeout and/or max_allowed_packet but not what to try setting them to.
Any suggestions?

Nextcloud version (eg, 20.0.5): 27.0.1
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04.2 LTS
Apache or nginx version (eg, Apache 2.4.25): nginx/1.25.1
PHP version (eg, 7.4): 8.1

The issue you are facing:
while running occ upgrade I get:
Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away Update failed

Is this the first time you’ve seen this error? N:

Steps to replicate it:

  1. upgrade the source files
  2. run occ upgrade

The output of your Nextcloud log in Admin > Logging:

N/A

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

<?php
$CONFIG = array (
  'instanceid' => 'oco3qvsccccw',
  'passwordsalt' => well salted',
  'secret' => 'top secret,
  'trusted_domains' => 
  array (
    0 => 'url',
  ),
  'datadirectory' => 'data path,
  'dbtype' => 'mysql',
  'version' => '27.0.0.8',
  'overwrite.cli.url' => 'url',
  'dbname' => 'dbname',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'dbuser',
  'dbpassword' => 'pw',
  'installed' => true,
  'loglevel' => 2,
  'maintenance' => true,
  'mail_from_address' => 'nextcloud',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'domain',
  'mail_smtphost' => server',
  'mail_smtpport' => '465',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'email',
  'mail_smtppassword' => 'password',
  'theme' => '',
  'default_phone_region' => 'US',
  'dbpersistent' => '',
);

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

PASTE HERE

PASTE HERE


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.

PASTE HERE

https://docs.nextcloud.com/server/latest/admin_manual/configuration_database/linux_database_configuration.html?highlight=2006#how-to-work-around-general-error-2006-mysql-server-has-gone-away

All of my MySQL settings are as shown in that guide. Anything else?

Not according to your provided config.php[1] so I presume you set wait_timeout on your MySQL server some other way?

What are the compute resources like for the server you’re running this all on?

What’s the usage like (memory/cpu/disk-io) during these periods?

Are there any other “has gone away” messages in your Nextcloud logs? (i.e. during other times than just during upgrades)?

[1] Configuration Parameters — Nextcloud latest Administration Manual latest documentation