Upgrade of Nextcloud from 27.0.1 to 27.0.2 results in instance being stuck in maintenance mode

Nextcloud version: 27.0.2
Operating system and version: Ubuntu 22.04.3 LTS
Apache or nginx version: Apache/2.4.52 (Ubuntu)
PHP version: PHP 8.1.2-1ubuntu2.13

The issue you are facing:

This was resolved with a server reboot, but I do not believe this should be necessary, hence the output below.

Following my update of Nextcloud to 27.0.2 via the web updater (which reported success), the instance presents me with the following: This Surfrock66 Nextcloud instance is currently in maintenance mode, which may take a while. This page will refresh itself when the instance is available again. Contact your system administrator if this message persists or appeared unexpectedly.

I checked the logs and saw nothing relevant. I then tried the following at the CLI, which did not resolve it:

sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off

Additionally, I tried a repair with the following sequence which also did not change the situation:

sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on
sudo -u www-data php /var/www/nextcloud/occ upgrade
sudo -u www-data php /var/www/nextcloud/occ maintenance:repair
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off

Lastly, I confirmed that config.php shows maintenance mode as false.

Rebooting the nextcloud web server fixed the issue, but I think that is likely an issue in many cases.

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

Steps to replicate it:

  1. Load the web page, see the error.

The output of your Nextcloud log in Admin > Logging:

Inaccessible at this time

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

<?php
$CONFIG = array (
  'instanceid' => '---',
  'passwordsalt' => '---',
  'secret' => '---',
  'trusted_domains' => 
  array (
    0 => '----',
    1 => '-----',
    2 => '----',
    3 => '-------',
  ),
  'trusted_proxies' => 
  array (
    0 => '10.2.2.10',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'defaultapp' => 'files',
  'version' => '27.0.2.1',
  'overwritehost' => '------',
  'overwriteprotocol' => 'https',
  'overwritewebroot' => '/',
  'overwrite.cli.url' => 'https://------',
  'htaccess.RewriteBase' => '/',
  'dbname' => 'nextcloud',
  'dbhost' => '------:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'usr_nextcloud',
  'dbpassword' => '-------,
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'maintenance' => false,
  'theme' => '',
  'localstorage.umask' => 2,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'loglevel' => 2,
  'mail_from_address' => 'nextcloud',
  'mail_smtpmode' => 'sendmail',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => '------',
  'mail_smtphost' => 'localhost',
  'mail_smtpport' => '25',
  'default_phone_region' => 'US',
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'app_install_overwrite' => 
  array (
    0 => 'files_3d',
    1 => 'files_texteditor',
    2 => 'printer',
    3 => 'epubreader',
    4 => 'richdocumentscode',
    5 => 'breezedark',
    6 => 'apporder',
    7 => 'ldap_write_support',
  ),
  'trashbin_retention_obligation' => 'auto,15',
  'allow_local_remote_servers' => true,
  'mail_smtpsecure' => 'ssl',
  'filelocking.enabled' => 'true',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/run/redis/redis-server.sock',
    'port' => 0,
    'dbindex' => 0,
    'password' => '',
    'timeout' => 1.5,
  ),
  'updater.secret' => '--------',
);

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

Nothing except for a few timeouts to my reverse proxy:

[Thu Aug 10 08:06:50.220473 2023] [proxy_fcgi:error] [pid 1392268:tid 139630527641152] (70007)The timeout specified has expired: [client 10.2.2.212:52740] AH01075: Error dispatching request to : (polling)

PASTE HERE

{"reqId":"rVx4IRxptP2pVH5cSLHU","level":3,"time":"2023-08-10T09:43:55+00:00","remoteAddr":"10.2.2.212","user":"0c904fda-590e-103b-8ab3-8f73b30b6c02","app":"webdav","method":"PROPFIND","url":"/remote.php/dav/files/0c904fda-590e-103b-8ab3-
8f73b30b6c02/","message":"OC\\DB\\Exceptions\\DbalException: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction","userAgent":"Mozilla/5.0 (Windows) m
irall/3.4.0stable-Win64 (build 20211129) (Nextcloud, windows-10.0.22621 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"27.0.1.2","exception":{"Exception":"Sabre\\DAV\\Exception\\ServiceUnavailable","Message":"OC\\DB\\Exce
ptions\\DbalException: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction","Code":0,"Trace":[{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/Wil
dcardEmitterTrait.php","line":89,"function":"{closure}","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":456,"function":"emit","class":"Sabre\\DAV\\Server","type"
:"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"funct
ion":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":77,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":174,"function":"handleExc
eption"}],"File":"/var/www/nextcloud/remote.php","Line":75,"message":"OC\\DB\\Exceptions\\DbalException: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting trans
action","exception":{},"CustomMessage":"OC\\DB\\Exceptions\\DbalException: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction"}}

Following this I checked the health of the sql server and there are no hanging processes; I restarted services just to check to no avail. In troubleshooting I restarted the sql server which did not resolve the issue.

A reboot was likely unnecessary. A bump to the Apache server probably would have been enough. It may have taken care of itself eventually, depending on your opcache.revalidate_freq setting (though it’s possible to set it such that it never do so).

At least that’s my guess.