marius-wieschollek / passwords

A simple, yet feature rich password manager for Nextcloud
GNU Affero General Public License v3.0
211 stars 45 forks source link

The new stable version 2018.6.0 leaves the server stuck in maintenance mode #52

Closed XUBIUM closed 6 years ago

XUBIUM commented 6 years ago

Hello,

When we press the update button for the newest version from the app list of NextCloud, the button text stays in updating and the server gets stuck in maintenance mode. This is only happening with this update, and we have tried 3 times with the same result.

System Information

Best regards,

Fernando Covecino

marius-wieschollek commented 6 years ago

Is there any information in the nextcloud log?

XUBIUM commented 6 years ago

What file do I need to check for that?

marius-wieschollek commented 6 years ago

Usually you can find the log in the admin interface ("Settings" > "Logging"). Otherwise the log itself can be found in data/nextcloud.log. But that is pretty unreadable.

It could be that you have more success downloading the app manually and unpack the files on your server and then run the upgrade via ./occ upgrade from the command line.

XUBIUM commented 6 years ago

The issue is that, since I'm using a shared hosting, I can't run commands in a CLI. And when the system gets stuck in maintenance mode what I do is a restore (I loose access to the interface, so I can't read the log from there). Would it help if I try the update, zip the log file before restoring, and send it to you?

marius-wieschollek commented 6 years ago

If you have write access, you can just go and set the maintenance flag in the config.php to false and check the error log then.

XUBIUM commented 6 years ago

I turned off the he maintenance flag and then it asked to upgrade and successfully repaired the app, but I can see this error en in the log:

TypeError: Argument 1 passed to OCA\Passwords\Services\Object\AbstractModelService::__construct() must be of the type string or null, object given, called in /home/xubiumco/teams.xubium.com/apps/passwords/lib/Services/Object/TagService.php on line 40

/home/xubiumco/teams.xubium.com/apps/passwords/lib/Services/Object/TagService.php - line 40: OCA\Passwords\Services\Object\AbstractModelService->__construct(Object(OCA\Passwords\Hooks\Manager\HookManager), Object(OCA\Passwords\Db\TagMapper), Object(OCA\Passwords\Services\EnvironmentService))
[internal function] OCA\Passwords\Services\Object\TagService->__construct(Object(OCA\Passwords\Hooks\Manager\HookManager), Object(OCA\Passwords\Db\TagMapper), Object(OCA\Passwords\Services\EnvironmentService))
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/Utility/SimpleContainer.php - line 80: ReflectionClass->newInstanceArgs(Array)
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/Utility/SimpleContainer.php - line 97: OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/Utility/SimpleContainer.php - line 118: OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Passwords\\S...')
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/DependencyInjection/DIContainer.php - line 467: OC\AppFramework\Utility\SimpleContainer->query('OCA\\Passwords\\S...')
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/DependencyInjection/DIContainer.php - line 438: OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\Passwords\\S...')
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/Utility/SimpleContainer.php - line 67: OC\AppFramework\DependencyInjection\DIContainer->query('OCA\\Passwords\\S...')
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/Utility/SimpleContainer.php - line 97: OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/Utility/SimpleContainer.php - line 118: OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Passwords\\M...')
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/DependencyInjection/DIContainer.php - line 467: OC\AppFramework\Utility\SimpleContainer->query('OCA\\Passwords\\M...')
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/DependencyInjection/DIContainer.php - line 438: OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\Passwords\\M...')
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/Utility/SimpleContainer.php - line 67: OC\AppFramework\DependencyInjection\DIContainer->query('OCA\\Passwords\\M...')
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/Utility/SimpleContainer.php - line 97: OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/Utility/SimpleContainer.php - line 118: OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Passwords\\M...')
/home/xubiumco/teams.xubium.com/lib/private/AppFramework/DependencyInjection/DIContainer.php - line 467: OC\AppFramework\Utility\SimpleContainer->query('OCA\\Passwords\\M...')
/home/xubiumco/teams.xubium.com/lib/private/ServerContainer.php - line 116: OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\Passwords\\M...')
/home/xubiumco/teams.xubium.com/lib/private/Repair.php - line 106: OC\ServerContainer->query('OCA\\Passwords\\M...')
/home/xubiumco/teams.xubium.com/lib/private/legacy/app.php - line 1107: OC\Repair->addStep('OCA\\Passwords\\M...')
/home/xubiumco/teams.xubium.com/lib/private/legacy/app.php - line 1050: OC_App executeRepairSteps('passwords', Array)
/home/xubiumco/teams.xubium.com/lib/private/Installer.php - line 201: OC_App updateApp('passwords')
/home/xubiumco/teams.xubium.com/settings/ajax/updateapp.php - line 45: OC\Installer->updateAppstoreApp('passwords')
/home/xubiumco/teams.xubium.com/lib/private/Route/Route.php - line 155: require_once('/home/xubiumco/...')
[internal function] OC\Route\Route->OC\Route\{closure}(*** sensitive parameters replaced ***)
/home/xubiumco/teams.xubium.com/lib/private/Route/Router.php - line 297: call_user_func(Object(Closure), Array)
/home/xubiumco/teams.xubium.com/lib/base.php - line 999: OC\Route\Router->match('/settings/ajax/...')
/home/xubiumco/teams.xubium.com/index.php - line 37: OC handleRequest()
{main}
marius-wieschollek commented 6 years ago

Does the app operate normally?

XUBIUM commented 6 years ago

Now, after the repair that the system executed automatically, it operates normally and appears to be the new version.

XUBIUM commented 6 years ago

The broken passwords are fixed.

marius-wieschollek commented 6 years ago

Well, the log sadly leaves out the interesting details, but to me it looks like Nextcloud ran into an error while trying to resolve the php class dependencies. I don'T know why, but i will try to replicate the error.

The broken passwords are fixed. I assume you mean the issue where passwords are marked as bad even if they aren't.

If you have access to your database, you can go and check the table appconfig. There should be an entry where the appid is passwords, the configkey is database_version and the value is 1

XUBIUM commented 6 years ago

About: I assume you mean the issue where passwords are marked as bad even if they aren't. Yes... NextCloud doesn't report that the app needs an update, and I guess it is true because the issue is gone.

XUBIUM commented 6 years ago

How do I help you to troubleshoot this? If you want to see it directly we can setup a remote session so you check it out first hand... whatever helps...

marius-wieschollek commented 6 years ago

The thing i would like to figure out is which of the migrations have been executed. There are three migrations in the app: The legacy migration where the error seems to have happened, the database fields migration and the haveibeenpwned fix. The database migration is a tricky one because you will not see an error until you use a function that requires it. If the database_version field is set to 1, everything is fine, if not you should probably try to run the repair mode.

XUBIUM commented 6 years ago

The configvalue is set to 1 in the row with appid passwords and configkey database_version. How can I help you further?

marius-wieschollek commented 6 years ago

Ok. i will see if i can reproduce the error on my testing environment,

Is there anything unusual about your server? Which database server do you use? (mysql/mariadb/postgres/sqlite) Which version did you have installed before? What memory_limit and max_execution_time are set for php? Are you using ldap or any other user backend? And which way are you executing background jobs? (ajax/webcron/cron)

XUBIUM commented 6 years ago

I don't know of anything unusual with the server, everythig has worked perfectly until this update. The database is mysql I had the previous version (I update regularily) memory_limit = 640MBs and max_execution_time 60 secs No ldap or other backend AJAX

marius-wieschollek commented 6 years ago

Ok, I think i can reproduce the issue. Your server is fine

It's quite a difficult problem. When the passwords app gets initialized, it registers some system hooks. These hooks of course load php classes. One of these hooks will load the FolderService which loads the AbstractModelService. When the Nextcloud updater wants to update the app, it will download the new code and then run the migrations from the new codebase. Now there is the tricky part: Classes which have already been loaded will not be loaded again. In the case of the legacy migration this means that the TagService will be loaded from the new code base, but the AbstractModelService (which is used by the TagService) has already been loaded and will be from the old code base. But since the class constructor has been changed, those two classes are now incompatible. And that causes the crash.

So basically the Nextcloud updater mixes the old and the new codebase and that causes the crash because the two codebases are incompatible. I will have to figure out a way to fix this. Probably the best way is to just go and remove the legacy migration.

marius-wieschollek commented 6 years ago

Since this will probably affect anyone trying to upgrade via the appstore, here's a workaround:

From the command line:

./occ maintenance:mode --off
./occ config:app:set passwords installed_version --value 2018.5.2
./occ upgrade

If you can't use the command line:

XUBIUM commented 6 years ago

In my case, it worked without the step in the 2nd bullet... Should I run that command now?

marius-wieschollek commented 6 years ago

No, your server seems to have run the other upgrades just fine. The legacy migration is just for people who had Fallon Turners Password app for OwnCloud installed.

Thanks for reporting this bug.

marius-wieschollek commented 6 years ago

Ok. 2018.6.3 should fix the upgrade issue.