Snap Nextcloud - Internal Server Error

Hi,
Randomly yesterday at 2am, my nextcloud server website stopped working with an Internal Server Error message.
On checking the logs in “/var/snap/nextcloud/current/logs”
The only one that shows anything useful is “mysql_errors.log”, and it shows this error several times a second since the 2am:

2020-10-15T10:16:49.873588Z 561 [Note] Access denied for user ‘nextcloud’@‘localhost’ (using password: YES)

No idea why it started doing this… so I ran these to grant this access access to the database again (as sudo):

nextcloud.mysql-client -S /tmp/sockets/mysql.sock
ALTER USER nextcloud@localhost IDENTIFIED BY ‘SomePassword1’;
use mysql;
GRANT ALL PRIVILEGES ON . TO nextcloud@locahost;
FLUSH PRIVILEGES;

Then rebooted.
And the error goes away, but the website still shows internal server error.

After some googling I found this command to do some commands against nextcloud:
Nextcloud.occ

but when running this I get a load of errors:

An unhandled exception has been thrown:
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘nextcloud.oc_appconfig’ doesn’t exist in /snap/nextcloud/23743/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:88
Stack trace:
#0 /snap/nextcloud/23743/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(88): PDO->query(‘SELECT * FROM ...') #1 /snap/nextcloud/23743/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(908): Doctrine\DBAL\Driver\PDOConnection->query('SELECT * FROM …’)
#2 /snap/nextcloud/23743/htdocs/lib/private/DB/Connection.php(194): Doctrine\DBAL\Connection->executeQuery(‘SELECT * FROM ...', Array, Array, NULL) #3 /snap/nextcloud/23743/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php(200): OC\DB\Connection->executeQuery('SELECT * FROM …’, Array, Array)
#4 /snap/nextcloud/23743/htdocs/lib/private/DB/QueryBuilder/QueryBuilder.php(216): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /snap/nextcloud/23743/htdocs/lib/private/AppConfig.php(331): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /snap/nextcloud/23743/htdocs/lib/private/AppConfig.php(109): OC\AppConfig->loadConfigValues()
#7 /snap/nextcloud/23743/htdocs/lib/private/AppConfig.php(287): OC\AppConfig->getApps()
#8 /snap/nextcloud/23743/htdocs/lib/private/legacy/OC_App.php(883): OC\AppConfig->getValues(false, ‘installed_versi…’)
#9 /snap/nextcloud/23743/htdocs/lib/private/Server.php(665): OC_App::getAppVersions()
#10 /snap/nextcloud/23743/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))
#11 /snap/nextcloud/23743/htdocs/lib/private/ServerContainer.php(124): Pimple\Container->offsetGet(‘OC\Memcache\Fac…’)
#12 /snap/nextcloud/23743/htdocs/lib/private/Server.php(1704): OC\ServerContainer->query(‘OC\Memcache\Fac…’)
#13 /snap/nextcloud/23743/htdocs/lib/private/Server.php(856): OC\Server->getMemCacheFactory()
#14 /snap/nextcloud/23743/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))
#15 /snap/nextcloud/23743/htdocs/lib/private/ServerContainer.php(124): Pimple\Container->offsetGet(‘OC\App\AppManag…’)
#16 /snap/nextcloud/23743/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(163): OC\ServerContainer->query(‘OC\App\AppManag…’)
#17 /snap/nextcloud/23743/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))
#18 /snap/nextcloud/23743/htdocs/lib/private/ServerContainer.php(124): Pimple\Container->offsetGet(‘OCP\App\IAppMan…’)
#19 /snap/nextcloud/23743/htdocs/lib/private/Server.php(1894): OC\ServerContainer->query(‘OCP\App\IAppMan…’)
#20 /snap/nextcloud/23743/htdocs/lib/private/legacy/OC_App.php(347): OC\Server->getAppManager()
#21 /snap/nextcloud/23743/htdocs/lib/private/legacy/OC_App.php(114): OC_App::getEnabledApps()
#22 /snap/nextcloud/23743/htdocs/lib/base.php(648): OC_App::loadApps(Array)
#23 /snap/nextcloud/23743/htdocs/lib/base.php(1094): OC::init()
#24 /snap/nextcloud/23743/htdocs/console.php(49): require_once(’/snap/nextcloud…’)
#25 /snap/nextcloud/23743/htdocs/occ(11): require_once(’/snap/nextcloud…’)
#26 {main}

Next Doctrine\DBAL\Driver\PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘nextcloud.oc_appconfig’ doesn’t exist in /snap/nextcloud/23743/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:90
Stack trace:
#0 /snap/nextcloud/23743/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(908): Doctrine\DBAL\Driver\PDOConnection->query(‘SELECT * FROM ...') #1 /snap/nextcloud/23743/htdocs/lib/private/DB/Connection.php(194): Doctrine\DBAL\Connection->executeQuery('SELECT * FROM …’, Array, Array, NULL)
#2 /snap/nextcloud/23743/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php(200): OC\DB\Connection->executeQuery(‘SELECT * FROM `…’, Array, Array)
#3 /snap/nextcloud/23743/htdocs/lib/private/DB/QueryBuilder/QueryBuilder.php(216): Doctrine\DBAL\Query\QueryBuilder->execute()
#4 /snap/nextcloud/23743/htdocs/lib/private/AppConfig.php(331): OC\DB\QueryBuilder\QueryBuilder->execute()
#5 /snap/nextcloud/23743/htdocs/lib/private/AppConfig.php(109): OC\AppConfig->loadConfigValues()
#6 /snap/nextcloud/23743/htdocs/lib/private/AppConfig.php(287): OC\AppConfig->getApps()
#7 /snap/nextcloud/23743/htdocs/lib/private/legacy/OC_App.php(883): OC\AppConfig->getValues(false, ‘installed_versi…’)
#8 /snap/nextcloud/23743/htdocs/lib/private/Server.php(665): OC_App::getAppVersions()
#9 /snap/nextcloud/23743/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))
#10 /snap/nextcloud/23743/htdocs/lib/private/ServerContainer.php(124): Pimple\Container->offsetGet(‘OC\Memcache\Fac…’)
#11 /snap/nextcloud/23743/htdocs/lib/private/Server.php(1704): OC\ServerContainer->query(‘OC\Memcache\Fac…’)
#12 /snap/nextcloud/23743/htdocs/lib/private/Server.php(856): OC\Server->getMemCacheFactory()
#13 /snap/nextcloud/23743/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))
#14 /snap/nextcloud/23743/htdocs/lib/private/ServerContainer.php(124): Pimple\Container->offsetGet(‘OC\App\AppManag…’)
#15 /snap/nextcloud/23743/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(163): OC\ServerContainer->query(‘OC\App\AppManag…’)
#16 /snap/nextcloud/23743/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))
#17 /snap/nextcloud/23743/htdocs/lib/private/ServerContainer.php(124): Pimple\Container->offsetGet(‘OCP\App\IAppMan…’)
#18 /snap/nextcloud/23743/htdocs/lib/private/Server.php(1894): OC\ServerContainer->query(‘OCP\App\IAppMan…’)
#19 /snap/nextcloud/23743/htdocs/lib/private/legacy/OC_App.php(347): OC\Server->getAppManager()
#20 /snap/nextcloud/23743/htdocs/lib/private/legacy/OC_App.php(114): OC_App::getEnabledApps()
#21 /snap/nextcloud/23743/htdocs/lib/base.php(648): OC_App::loadApps(Array)
#22 /snap/nextcloud/23743/htdocs/lib/base.php(1094): OC::init()
#23 /snap/nextcloud/23743/htdocs/console.php(49): require_once(’/snap/nextcloud…’)
#24 /snap/nextcloud/23743/htdocs/occ(11): require_once(’/snap/nextcloud…’)
#25 {main}

Next Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT * FROM oc_appconfig':

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘nextcloud.oc_appconfig’ doesn’t exist in /snap/nextcloud/23743/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:42
Stack trace:
#0 /snap/nextcloud/23743/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php(169): Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException(‘An exception oc…’, Object(Doctrine\DBAL\Driver\PDOException))
#1 /snap/nextcloud/23743/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php(145): Doctrine\DBAL\DBALException::wrapException(Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Driver\PDOException), ‘An exception oc…’)
#2 /snap/nextcloud/23743/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(911): Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Driver\PDOException), ‘SELECT * FROM ...', Array) #3 /snap/nextcloud/23743/htdocs/lib/private/DB/Connection.php(194): Doctrine\DBAL\Connection->executeQuery('SELECT * FROM …’, Array, Array, NULL)
#4 /snap/nextcloud/23743/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php(200): OC\DB\Connection->executeQuery(‘SELECT * FROM `…’, Array, Array)
#5 /snap/nextcloud/23743/htdocs/lib/private/DB/QueryBuilder/QueryBuilder.php(216): Doctrine\DBAL\Query\QueryBuilder->execute()
#6 /snap/nextcloud/23743/htdocs/lib/private/AppConfig.php(331): OC\DB\QueryBuilder\QueryBuilder->execute()
#7 /snap/nextcloud/23743/htdocs/lib/private/AppConfig.php(109): OC\AppConfig->loadConfigValues()
#8 /snap/nextcloud/23743/htdocs/lib/private/AppConfig.php(287): OC\AppConfig->getApps()
#9 /snap/nextcloud/23743/htdocs/lib/private/legacy/OC_App.php(883): OC\AppConfig->getValues(false, ‘installed_versi…’)
#10 /snap/nextcloud/23743/htdocs/lib/private/Server.php(665): OC_App::getAppVersions()
#11 /snap/nextcloud/23743/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))
#12 /snap/nextcloud/23743/htdocs/lib/private/ServerContainer.php(124): Pimple\Container->offsetGet(‘OC\Memcache\Fac…’)
#13 /snap/nextcloud/23743/htdocs/lib/private/Server.php(1704): OC\ServerContainer->query(‘OC\Memcache\Fac…’)
#14 /snap/nextcloud/23743/htdocs/lib/private/Server.php(856): OC\Server->getMemCacheFactory()
#15 /snap/nextcloud/23743/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))
#16 /snap/nextcloud/23743/htdocs/lib/private/ServerContainer.php(124): Pimple\Container->offsetGet(‘OC\App\AppManag…’)
#17 /snap/nextcloud/23743/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(163): OC\ServerContainer->query(‘OC\App\AppManag…’)
#18 /snap/nextcloud/23743/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))
#19 /snap/nextcloud/23743/htdocs/lib/private/ServerContainer.php(124): Pimple\Container->offsetGet(‘OCP\App\IAppMan…’)
#20 /snap/nextcloud/23743/htdocs/lib/private/Server.php(1894): OC\ServerContainer->query(‘OCP\App\IAppMan…’)
#21 /snap/nextcloud/23743/htdocs/lib/private/legacy/OC_App.php(347): OC\Server->getAppManager()
#22 /snap/nextcloud/23743/htdocs/lib/private/legacy/OC_App.php(114): OC_App::getEnabledApps()
#23 /snap/nextcloud/23743/htdocs/lib/base.php(648): OC_App::loadApps(Array)
#24 /snap/nextcloud/23743/htdocs/lib/base.php(1094): OC::init()
#25 /snap/nextcloud/23743/htdocs/console.php(49): require_once(’/snap/nextcloud…’)
#26 /snap/nextcloud/23743/htdocs/occ(11): require_once(’/snap/nextcloud…’)

which seems to point to “nextcloud.oc_appconfig”
But I am unsure as to what to do next… The other log files in the previous directory so no unusual or different errors… and the “mysql_errors.log” looks normal now.

… So I then went to restore from a backup… I tried a few, but the latest was from 2 weeks ago…
about a minute after starting up… I get the same old Internal Server Error, and the same Access denied for the database user.

So there is obviously something time based causing this issue… but I have no idea what or where to look.

So hopefully someone out there can help?

Thanks,

Tim Jeens

So, I think I have it figured out…
I managed to get it working again by upgrading my Ubuntu install from 18.04LTS to 20.04LTS (the latest).
But still not working.
But then issuing this command:
snap revert nextcloud

This reverted it from version 19.0.4 to 19.0.3, and the site immediately sprang to life.
The system must have auto updated to this overnight.
So there is something in my set up and version 19.0.4 that are not compatible.

So if anyone has any ideas on what that could be, or how to find out that would be useful.

Thanks,
Tim

Ok so now I have to do this revert daily…
I’ve even tried skipping versions to v20.0.1snap1, but even that version is broken…
There must be some incompatibility in my install that is breaking when I upgrade to anything over 19.0.3snap2.
Please can someone help.
Thanks,
Tim