mail-in-a-box / mailinabox

Mail-in-a-Box helps individuals take back control of their email by defining a one-click, easy-to-deploy SMTP+everything else server: a mail server in a box.
https://mailinabox.email/
Creative Commons Zero v1.0 Universal
14k stars 1.44k forks source link

Upgrade v0.23a to v0.24 fails when updating nextcloud #1257

Open hnk opened 7 years ago

hnk commented 7 years ago

Hi folks. Sadly my upgrade to v0.24 failed :(

Had this error pop up:

Installing Nextcloud (contacts/calendar)...
upgrading ownCloud/Nextcloud to  12.0.3 (backing up existing installation, configuration and database to directory to /home/user-data/owncloud-backup/2017-10-07-00:11:51...
We are running Nextcloud 10.0.x, upgrading to Nextcloud 11.0.3 first

Upgrading to Nextcloud version 11.0.3

An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /usr/local/lib/owncloud/lib/private/DB/Connection.php:60
Stack trace:
#0 /usr/local/lib/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /usr/local/lib/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /usr/local/lib/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /usr/local/lib/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(621): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /usr/local/lib/owncloud/lib/private/DB/Connection.php(147): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /usr/local/lib/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#6 /usr/local/lib/owncloud/lib/private/DB/ConnectionFactory.php(131): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#7 /usr/local/lib/owncloud/lib/private/Server.php(469): OC\DB\ConnectionFactory->getConnection('mysql', Array)
#8 /usr/local/lib/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#9 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): Pimple\Container->offsetGet('DatabaseConnect...')
#10 /usr/local/lib/owncloud/lib/private/ServerContainer.php(89): OC\AppFramework\Utility\SimpleContainer->query('DatabaseConnect...')
#11 /usr/local/lib/owncloud/lib/private/Server.php(1119): OC\ServerContainer->query('DatabaseConnect...')
#12 /usr/local/lib/owncloud/lib/private/Server.php(250): OC\Server->getDatabaseConnection()
#13 /usr/local/lib/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#14 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): Pimple\Container->offsetGet('OC\\Authenticati...')
#15 /usr/local/lib/owncloud/lib/private/ServerContainer.php(89): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#16 /usr/local/lib/owncloud/lib/private/Server.php(254): OC\ServerContainer->query('OC\\Authenticati...')
#17 /usr/local/lib/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#18 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): Pimple\Container->offsetGet('OC\\Authenticati...')
#19 /usr/local/lib/owncloud/lib/private/ServerContainer.php(89): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#20 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(163): OC\ServerContainer->query('OC\\Authenticati...')
#21 /usr/local/lib/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#22 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): Pimple\Container->offsetGet('OC\\Authenticati...')
#23 /usr/local/lib/owncloud/lib/private/ServerContainer.php(89): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#24 /usr/local/lib/owncloud/lib/private/Server.php(269): OC\ServerContainer->query('OC\\Authenticati...')
#25 /usr/local/lib/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#26 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): Pimple\Container->offsetGet('UserSession')
#27 /usr/local/lib/owncloud/lib/private/ServerContainer.php(89): OC\AppFramework\Utility\SimpleContainer->query('UserSession')
#28 /usr/local/lib/owncloud/lib/private/Server.php(988): OC\ServerContainer->query('UserSession')
#29 /usr/local/lib/owncloud/lib/private/Server.php(513): OC\Server->getUserSession()
#30 /usr/local/lib/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#31 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): Pimple\Container->offsetGet('AppManager')
#32 /usr/local/lib/owncloud/lib/private/ServerContainer.php(89): OC\AppFramework\Utility\SimpleContainer->query('AppManager')
#33 /usr/local/lib/owncloud/lib/private/Server.php(1296): OC\ServerContainer->query('AppManager')
#34 /usr/local/lib/owncloud/lib/private/legacy/app.php(320): OC\Server->getAppManager()
#35 /usr/local/lib/owncloud/lib/private/legacy/app.php(111): OC_App::getEnabledApps()
#36 /usr/local/lib/owncloud/lib/base.php(676): OC_App::loadApps(Array)
#37 /usr/local/lib/owncloud/lib/base.php(1092): OC::init()
#38 /usr/local/lib/owncloud/console.php(48): require_once('/usr/local/lib/...')
#39 /usr/local/lib/owncloud/occ(11): require_once('/usr/local/lib/...')
#40 {main}Trying ownCloud upgrade again to work around ownCloud upgrade bug...
An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /usr/local/lib/owncloud/lib/private/DB/Connection.php:60
Stack trace:
#0 /usr/local/lib/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /usr/local/lib/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /usr/local/lib/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /usr/local/lib/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(621): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /usr/local/lib/owncloud/lib/private/DB/Connection.php(147): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /usr/local/lib/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#6 /usr/local/lib/owncloud/lib/private/DB/ConnectionFactory.php(131): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#7 /usr/local/lib/owncloud/lib/private/Server.php(469): OC\DB\ConnectionFactory->getConnection('mysql', Array)
#8 /usr/local/lib/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#9 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): Pimple\Container->offsetGet('DatabaseConnect...')
#10 /usr/local/lib/owncloud/lib/private/ServerContainer.php(89): OC\AppFramework\Utility\SimpleContainer->query('DatabaseConnect...')
#11 /usr/local/lib/owncloud/lib/private/Server.php(1119): OC\ServerContainer->query('DatabaseConnect...')
#12 /usr/local/lib/owncloud/lib/private/Server.php(250): OC\Server->getDatabaseConnection()
#13 /usr/local/lib/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#14 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): Pimple\Container->offsetGet('OC\\Authenticati...')
#15 /usr/local/lib/owncloud/lib/private/ServerContainer.php(89): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#16 /usr/local/lib/owncloud/lib/private/Server.php(254): OC\ServerContainer->query('OC\\Authenticati...')
#17 /usr/local/lib/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#18 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): Pimple\Container->offsetGet('OC\\Authenticati...')
#19 /usr/local/lib/owncloud/lib/private/ServerContainer.php(89): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#20 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(163): OC\ServerContainer->query('OC\\Authenticati...')
#21 /usr/local/lib/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#22 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): Pimple\Container->offsetGet('OC\\Authenticati...')
#23 /usr/local/lib/owncloud/lib/private/ServerContainer.php(89): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#24 /usr/local/lib/owncloud/lib/private/Server.php(269): OC\ServerContainer->query('OC\\Authenticati...')
#25 /usr/local/lib/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#26 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): Pimple\Container->offsetGet('UserSession')
#27 /usr/local/lib/owncloud/lib/private/ServerContainer.php(89): OC\AppFramework\Utility\SimpleContainer->query('UserSession')
#28 /usr/local/lib/owncloud/lib/private/Server.php(988): OC\ServerContainer->query('UserSession')
#29 /usr/local/lib/owncloud/lib/private/Server.php(513): OC\Server->getUserSession()
#30 /usr/local/lib/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#31 /usr/local/lib/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): Pimple\Container->offsetGet('AppManager')
#32 /usr/local/lib/owncloud/lib/private/ServerContainer.php(89): OC\AppFramework\Utility\SimpleContainer->query('AppManager')
#33 /usr/local/lib/owncloud/lib/private/Server.php(1296): OC\ServerContainer->query('AppManager')
#34 /usr/local/lib/owncloud/lib/private/legacy/app.php(320): OC\Server->getAppManager()
#35 /usr/local/lib/owncloud/lib/private/legacy/app.php(111): OC_App::getEnabledApps()
#36 /usr/local/lib/owncloud/lib/base.php(676): OC_App::loadApps(Array)
#37 /usr/local/lib/owncloud/lib/base.php(1092): OC::init()
#38 /usr/local/lib/owncloud/console.php(48): require_once('/usr/local/lib/...')
#39 /usr/local/lib/owncloud/occ(11): require_once('/usr/local/lib/...')

After digging around I figured I was missing a php7 module for mysql, so I went ahead and installed php7.0-mysql.

Re-running the upgrade then did not work, because nextcloud complained about upgrading between major versions. So I re-downloaded and moved nextcloud 10.0.5 to /usr/local/lib/owncloud and re-ran the upgrade.

This time nextcloud upgraded from 10 to 11 and then to 12 but again, complained:

<warning>Nextcloud is in maintenance mode</warning>
Maybe an upgrade is already in process. Please check the logfile (data/nextcloud.log). If you want to re-run the upgrade procedure, remove the "maintenance mode" from config.php and call this script again.

And I was dropped back to the promp, the upgrade just stopped.

So I ran: sudo -u www-data php /usr/local/lib/owncloud/occ maintenance:mode --off and re-ran the upgrade again.

This time the upgrade completed and my box is fine, even after a reboot. Phew. Glad I started this at midnight 😭

yodax commented 7 years ago

Glad you got it working again, it’s weird that you had to install MySQL, our setup doesn’t use it.

hnk commented 7 years ago

Hmm you are right. I was tired and did not think much about that...

Ok, so the cause was something different and installing php7.0-mysql may have helped by causing some other side effect. If it did not fix the problem: Then what did?

Maybe installing the package caused php to re-index modules so it could use the sqlite module? This is just a wild guess.

nomandera commented 7 years ago

Perhaps this is related

https://github.com/mail-in-a-box/mailinabox/issues/1259

nordurljosahvida commented 7 years ago

@hnk could it be that you had set NC to use an external DB from the NC admin settings? I had the same issue. Fixed it like you said with:

apt install php7.0-mysql.

wget https://download.nextcloud.com/server/releases/nextcloud-10.0.5.zip

unzip nextcloud-10.0.5.zip

mv /usr/local/lib/owncloud/ /usr/local/lib/owncloud-old/

mv nextcloud /usr/local/lib/owncloud

confirm new version with cat /usr/local/lib/owncloud/version.php [must be 10.0.5]

sudo mailinabox

sudo -u www-data php /usr/local/lib/owncloud/occ maintenance:mode --off

sudo mailinabox

hnk commented 7 years ago

@nikksno No, I have a vanilla install and did not edit or change any settings for miab or nextcloud.

I do think that installing php7.0-mysql had no effect on the upgrade, but maybe triggered a dependency install that was missing.

@anoma I will have to investigate logs more thoroughly to see what was going on. I was kinda stressed out these last few days, so could not dig into it further. I will have some more time soon.

I just wanted to quickly log the errors I had here and how to fix it in case others ran into the same issues.

nordurljosahvida commented 7 years ago

@hnk ok I see. Not sure why then.