Regular automatic maintenance mode

Nextcloud version (eg, 18.0.2): 20.0.4
Operating system and version (eg, Ubuntu 20.04): Debian 10.0.7
Apache or nginx version (eg, Apache 2.4.25): nginx 1.14.2
PHP version (eg, 7.1): php 7.3.19

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N): Yes and NO as all my other nextcloud container don’t behave like that but this one, it happens regularly, every few days…

Steps to replicate it:

  1. I check if monespace.defis.info is up
  2. it has switched to maintenance mode automatically without noticing
  3. I do an “sudo -u www-data php occ maintenance:mode --off”
  4. It works normally for some time (up to few days)
  5. I go back to check if it’s up
  6. it has switched to maintenance mode automatically without noticing

The output of your Nextcloud log in Admin > Logging:

Error	remote	Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory	
2021-01-01T12:20:16+0100
Error	PHP	Error: Uninitialized string offset: 0 at /var/www/html/nextcloud/apps/user_ldap/lib/Wizard.php#807	
2020-12-03T11:57:42+0100
Error	jsresourceloader	Could not find resource core/js/files/client.js to load	
2020-12-03T11:50:27+0100
Error	jsresourceloader	Could not find resource core/js/files/fileinfo.js to load	
2020-12-03T11:50:27+0100
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve OCA\Files_Versions\Versions\IVersionManager! Class can not be instantiated	
2020-12-03T10:49:41+0100
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve trashManager! Class trashManager does not exist	
2020-12-03T10:49:41+0100

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

<?php
$CONFIG = array (
  'passwordsalt' => 'ttttttttttt',
  'secret' => 'jjjjjjjjjj',
  'trusted_domains' => 
  array (
    0 => 'monespace.defis.info',
  ),
  'datadirectory' => '/var/www/html/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '20.0.4.0',
  'overwrite.cli.url' => 'https://monespace.defis.info',
  'dbname' => 'gggg',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'kk_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'bbbb',
  'dbpassword' => 'zzzz',
  'default_language' => 'fr',
  'default_locale' => 'fr_FR',
  'overwriteprotocol' => 'https',
  'memcache.local' => 'OC\\Memcache\\APCu',
  'installed' => true,
  'instanceid' => 'yyyy',
  'maintenance' => false,
  'mail_from_address' => 'nnnnnn',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'domain.com',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'ssl0.ovh.net',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'nnnnnn@domain.com',
  'mail_smtppassword' => 'XXXX',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'theme' => '',
  'loglevel' => 2,
);

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

$ cat /var/log/nginx/error.log
2021/01/01 11:29:38 [error] 150#150: *244 access forbidden by rule, client: 192.168.XXX.YYY, server: monespace.defis.info, request: "GET /data/.ocdata?t=1609500578064 HTTP/1.0", host: "monespace.defis.info"

$ tail /var/log/syslog
Jan  1 11:30:01 monespace CRON[515]: (www-data) CMD (php /var/www/html/nextcloud/cron.php)
Jan  1 11:35:01 monespace CRON[522]: (www-data) CMD (php /var/www/html/nextcloud/cron.php)
Jan  1 11:36:14 monespace systemd[1]: Starting Cleanup of Temporary Directories...
Jan  1 11:36:15 monespace systemd[1]: systemd-tmpfiles-clean.service: Succeeded.
Jan  1 11:36:15 monespace systemd[1]: Started Cleanup of Temporary Directories.
Jan  1 11:39:01 monespace CRON[528]: (root) CMD (  [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
Jan  1 11:39:01 monespace systemd[1]: Starting Clean php session files...
Jan  1 11:39:01 monespace systemd[1]: phpsessionclean.service: Succeeded.
Jan  1 11:39:01 monespace systemd[1]: Started Clean php session files.
Jan  1 11:40:01 monespace CRON[576]: (www-data) CMD (php /var/www/html/nextcloud/cron.php)

Hello @assodefis,

welcome to the community of Nextcloud.

Nextcloud has no built in feature to go maintenance mode automatically.

What happened here? You db wasn’t reachable.

I know it does not have any built in feature to go maintenance mode automatically that’s why I don’t understand what is going on.
Again today it is back on maintenance mode…

I checked the error you pointed and I don’t get it because if I understand well this error, it does indeed mean that the db was unreachable but I didn’t notice any problem with the db. This error occurred only once, at startup, when I tried yesterday to reboot nextcloud to see if that could solve the issue (but rebooting didn’t solve it as it was back in maintenance this morning).

I can try to reboot again and see if this issue occur again.

No, this error didn’t happen again after the reboot.

However, I guess I found the responsible of the mess… a borgbackup script … I corrected it and I’ll see if it was that. I’ll let you know.

Thank you @rakekniven for taking time to answer us.
Any idea where the error you highlighted could have come from?

What does it doing related to Nextcloud?