Built-in updater crashed when it was updating from 25.0.2 to 25.0.3 and it stoped working

Support intro

After Built-in updater 25.0.3 started working it shows server problem and now the webpage does not load, the server load is high when we try to use nextcloud services, it also collapses the database postgres for other web apps are installed in the same cluster.

Nextcloud version (eg, 20.0.5): 25.0.2 to 25.0.3
Operating system and version ( Ubuntu 20.04):
Apache or nginx version : Apache/2.4.41 (Ubuntu)
PHP version : 7.4.3-4ubuntu2.16

The issue you are facing:

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

Steps to replicate it:

  1. use the nextcloud server
  2. Server load comes high
  3. I collapses database
  4. The nextcloud server is not working properly, the website loads partially.

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

[Fri Jan 20 20:27:47.499152 2023] [php7:error] [pid 28720] [client 192.168.2.1:50196] script ‘/var/www/html/nextcloud/apps/richdocumentscode/proxy.php’ not found or unable to stat
[Fri Jan 20 20:27:47.564685 2023] [php7:error] [pid 28705] [client 192.168.2.1:50200] script ‘/var/www/html/nextcloud/apps/richdocumentscode/proxy.php’ not found or unable to stat
[Fri Jan 20 20:27:47.667276 2023] [php7:error] [pid 28727] [client 192.168.2.1:45956] PHP Fatal error: Uncaught Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] FATAL: remaining connection slots are reserved for non-replication superuser connections in /var/www/html/nextcloud/lib/private/DB/Connection.php:139\nStack trace:\n#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\DB\Connection->connect()\n#1 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\DBAL\Connection->getWrappedConnection()\n#2 /var/www/html/nextcloud/lib/private/DB/Connection.php(261): Doctrine\DBAL\Connection->executeQuery()\n#3 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()\n#4 /var/www/html/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(281): Doctrine\DBAL\Query\QueryBuilder->execute()\n#5 /var/www/html/nextcloud/lib/private/AppConfig.php(418): OC\DB\QueryBuilder\QueryBuilder->execute()\n#6 /var/www/html/nextcloud/lib/private/AppConfig.php(183): OC in /var/www/html/nextcloud/lib/private/DB/Connection.php on line 139
[Fri Jan 20 20:27:47.683358 2023] [php7:error] [pid 28723] [client 192.168.2.1:50214] script ‘/var/www/html/nextcloud/apps/richdocumentscode/proxy.php’ not found or unable to stat

THERE ARE THOUSANS OF 
[Fri Jan 20 20:27:47.702979 2023] [php7:error] [pid 28757] [client 192.168.2.1:50230] script '/var/www/html/nextcloud/apps/richdocumentscode/proxy.php' not found or unable to stat
[Fri Jan 20 20:33:52.512419 2023] [php7:error] [pid 28633] [client 192.168.2.1:37188] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] FATAL:  remaining connection slots are reserved for non-replication superuser connections in /var/www/html/nextcloud/lib/private/DB/Connection.php:139\nStack trace:\n#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\\DB\\Connection->connect()\n#1 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\\DBAL\\Connection->getWrappedConnection()\n#2 /var/www/html/nextcloud/lib/private/DB/Connection.php(261): Doctrine\\DBAL\\Connection->executeQuery()\n#3 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\\DB\\Connection->executeQuery()\n#4 /var/www/html/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(281): Doctrine\\DBAL\\Query\\QueryBuilder->execute()\n#5 /var/www/html/nextcloud/lib/private/AppConfig.php(418): OC\\DB\\QueryBuilder\\QueryBuilder->execute()\n#6 /var/www/html/nextcloud/lib/private/AppConfig.php(183): OC in /var/www/html/nextcloud/lib/private/DB/Connection.php on line 139
[Fri Jan 20 20:33:52.517105 2023] [php7:error] [pid 28511] [client 192.168.2.1:37186] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] FATAL:  remaining connection slots are reserved for non-replication superuser connections in /var/www/html/nextcloud/lib/private/DB/Connection.php:139\nStack trace:\n#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\\DB\\Connection->connect()\n#1 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\\DBAL\\Connection->getWrappedConnection()\n#2 /var/www/html/nextcloud/lib/private/DB/Connection.php(261): Doctrine\\DBAL\\Connection->executeQuery()\n#3 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\\DB\\Connection->executeQuery()\n#4 /var/www/html/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(281): Doctrine\\DBAL\\Query\\QueryBuilder->execute()\n#5 /var/www/html/nextcloud/lib/private/AppConfig.php(418): OC\\DB\\QueryBuilder\\QueryBuilder->execute()\n#6 /var/www/html/nextcloud/lib/private/AppConfig.php(183): OC in /var/www/html/nextcloud/lib/private/DB/Connection.php on line 139
[Fri Jan 20 20:33:52.558028 2023] [php7:error] [pid 28627] [client 192.168.2.1:47754] script '/var/www/html/nextcloud/apps/richdocumentscode/proxy.php' not found or unable to stat
[Fri Jan 20 20:33:52.576782 2023] [php7:error] [pid 79656] [client 192.168.2.1:47768] script '/var/www/html/nextcloud/apps/richdocumentscode/proxy.php' not found or unable to stat
[Fri Jan 20 20:33:52.577127 2023] [php7:error] [pid 37586] [client 192.168.2.1:47770] script '/var/www/html/nextcloud/apps/richdocumentscode/proxy.php' not found or unable to stat
[Fri Jan 20 20:33:52.585137 2023] [php7:error] [pid 63538] [client 192.168.2.1:37220] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] FATAL:  remaining connection slots are reserved for non-replication superuser connections in /var/www/html/nextcloud/lib/private/DB/Connection.php:139\nStack trace:\n#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\\DB\\Connection->connect()\n#1 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\\DBAL\\Connection->getWrappedConnection()\n#2 /var/www/html/nextcloud/lib/private/DB/Connection.php(261): Doctrine\\DBAL\\Connection->executeQuery()\n#3 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\\DB\\Connection->executeQuery()\n#4 /var/www/html/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(281): Doctrine\\DBAL\\Query\\QueryBuilder->execute()\n#5 /var/www/html/nextcloud/lib/private/AppConfig.php(418): OC\\DB\\QueryBuilder\\QueryBuilder->execute()\n#6 /var/www/html/nextcloud/lib/private/AppConfig.php(183): OC in /var/www/html/nextcloud/lib/private/DB/Connection.php on line 139
[Fri Jan 20 20:33:52.604030 2023] [php7:error] [pid 28633] [client 192.168.2.1:47782] script '/var/www/html/nextcloud/apps/richdocumentscode/proxy.php' not found or unable to stat
The output of your config.php file in `/path/to/nextcloud` (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'xxxxxxxxxxx',
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'trusted_domains' => 
  array (
    0 => '192.168.2.115',
    1 => 'xxx.xxx.xx.22',
    2 => 'www.xxxxxx.com',
  ),
  'datadirectory' => '/var/lib/nextcloud/data',
  'dbtype' => 'pgsql',
  'version' => '25.0.3.2',
  'overwrite.cli.url' => 'http://192.168.2.115/nextcloud',
  'dbname' => 'nextclouddbname',
  'dbhost' => 'localhost:5432',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextclouduser',
  'dbpassword' => 'NextcloudDBpass',
  'installed' => true,
  'onlyoffice' => 
  array (
    'verify_peer_off' => true,
  ),
  'allow_local_remote_servers' => true,
  'theme' => '',
  'maintenance' => false,
  'loglevel' => 0,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'news',
  'mail_domain' => 'email.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.imail.com',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'news@email.com',
  'mail_smtppassword' => 'emailPass',
  'updater.release.channel' => 'stable',
  'default_phone_region' => 'EC',
  'app_install_overwrite' => 
  array (
    0 => 'spreed',
  ),
  'updater.secret' => '$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
);

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

PHP Fatal error: Uncaught Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] FATAL: remaining connection slots are reserved for non-replication superuser connections in /var/www/html/nextcloud/lib/private/DB/Connection

hint: https://bobcares.com/blog/postgresql-remaining-connection-slots-are-reserved-error/

For my NC i used the PG Tune Website to optimize the PostgreSQL Server config e.g. the max_connections option as well.

use this site to find out what parameters fit to your NC
https://pgtune.leopard.in.ua/

after that check, that nc server can connect properly to the postgresql db.

For the “broken update” you should

  1. make a whole backup of your nc rootdir (e.g. /var/www/nextcloud → backup-folder)
  2. download the tar.bz2 or zip of the nextcloud 25.0.3 → download
    use wget command for servers with terminal only → wget URL-OF-THE-DOWNLOADLINK
  3. unpack the file to /tmp dir
  4. copy over the files from the unpacked folder /tmp/nextcloud-25.0.3 to your nc dir (e.g. /var/www/nextcloud)
  5. check ownership and access rights in nextcloud dir
    → owner www-data:www-data → files/folder chmod -R 750 …
  6. run occ upgrade command as webuser (e.g. www-data) again and don’t forget to check folder rights before (!)