Skip to content

Documents won't open after upgrade to version 3.5.3 #917

Closed

Description

@XUBIUM

Hello

Describe the bug
Documents won't open after upgrading to version 3.5.3.

To Reproduce
Steps to reproduce the behavior:

  1. Upgrade to version 3.5.3
  2. Try to create or open a document
  3. It won't open
  4. You will see in the log:

"/index.php/apps/richdocuments/indexTemplate?templateId=194402&fileName=Nuevo%20Documento.docx&dir=%2F&requesttoken=1hQrJbH4MLlQ3QvI2TqZDdXCScJ6ZYRUk7wSei2BnB4%3D%3AnHlGDvrNSvYnukqviG%2FVQ%2BOXO4xRMsUf%2FoRoLE%2FH6Cg%3D","message":{"Exception":"Doctrine\DBAL\Exception\InvalidFieldNameException","Message":"An exception occurred while executing 'INSERT INTO oc_richdocuments_wopi(fileid,owner_uid,editor_uid,version,canwrite,server_host,token,expiry,template_destination,hide_download,direct,is_remote_token,template_id) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)' with params [194402, "xubium", "xubium", 0, true, "https:\/\/\/", "hw8aTK2qJ8iFvG1ZVfcHUGK07NOs9P6N", 1587528003, 234882, false, false, false, 0]:\n\nSQLSTATE[42S22]: Column not found: 1054 Unknown column 'template_id' in 'field list'","Code":0,"Trace":

It seems that the migration contained in /lib/Migration/Version2060Date20200302131958.php is not correctly executed when upgrading. That migration adds the missing column:

$table->addColumn(‘template_id’, ‘integer’, [
‘notnull’ => false,
length’ => 4,
]);

Activity

  1. juliusknorr commented on Apr 22, 2020

    @juliusknorr
    Member

    Do you still have logs from the app update? I cannot see why the migration would not run.

  2. XUBIUM commented on Apr 22, 2020

    @XUBIUM
    Author

    I don't have the logs, but I will try to recreate the scenario from a backup and send you the information. By the way, thera are questions about this in the Nextcloud forum, it is not just me having the issue. I upgraded from 3.5.2 to 3.5.3.
    Give me until today EOD to try to get you the logs.
    Thanks for the support.

  3. XUBIUM commented on Apr 23, 2020

    @XUBIUM
    Author

    Hello,
    I can't find errors in the logs, and I jus installed a fresh Nextcloud to test and the 3.5.3 version is working ok on the fresh install.
    To solve this issue, would it be ok if I disable & delete the app, then delete oc_richdocuments_* tables from the database, and install again?
    Thanks

  4. juliusknorr commented on Apr 23, 2020

    @juliusknorr
    Member

    Running occ migrations:migrate richdocuments should already do the trick to fix a installation where the migration has not been running.

    Could you maybe check the output of occ migrations:status richdocuments upfront?

  5. XUBIUM commented on Apr 23, 2020

    @XUBIUM
    Author

    Hello,

    The output of occ migrations:status richdocuments before executing occ migrations:migrate richdocuments is:

    >> App:                                                richdocuments
    >> Version Table Name:                                 oc_migrations
    >> Migrations Namespace:                               OCA\Richdocuments\Migration
    >> Migrations Directory:                               /mnt/www2/xubium/nextcloud/apps/richdocuments/lib/Migration
    >> Previous Version:                                   2060Date20200302131958
    >> Current Version:                                    2060Date20200302132145
    >> Next Version:                                       Already at latest migration step
    >> Latest Version:                                     2060Date20200302132145
    >> Executed Migrations:                                2
    >> Executed Unavailable Migrations:                    2
    >> Available Migrations:                               2
    >> New Migrations:                                     2
    >> Pending Migrations:                                 None
    

    Then I executed occ migrations:migrate richdocuments, it didn't produce any output, it didn't fix the problem, and occ migrations:status richdocuments produces the exact same output.

    So to fix this, I could uninstall the App, delete from the DB the tables oc_richdocuments_* and then install again, right?

    Let me know if I can do more testing to help.

  6. juliusknorr commented on Apr 24, 2020

    @juliusknorr
    Member

    Hm that is really odd, the only way I can see this could happen is if someone upgrades from 3.4.x to 3.5.3 directly as then the migration would not create the column.

  7. XUBIUM commented on Apr 24, 2020

    @XUBIUM
    Author

    It would work if I uninstall, delete from the DB the tables oc_richdocuments_* and then install the app, right?

  8. iexos commented on Apr 24, 2020

    @iexos

    Please see also the help topic at here:

    https://help.nextcloud.com/t/error-when-starting-collabora-insert-into-oc-richdocuments-wopi/77451

    In my case, I tried setting up collabora a few months ago but couldn't get it to work for unknown reasons. Now I am experiencing the same error as above.

  9. juliusknorr commented on Apr 24, 2020

    @juliusknorr
    Member

    It would work if I uninstall, delete from the DB the tables oc_richdocuments_* and then install the app, right?

    Yes, but in addition you also need to clear the migrations for richdocuments, so it should be the following steps:

    • disable app
    • remove app folder
    • run the following sql statements:
      drop table oc_richdocuments_direct;
      drop table oc_richdocuments_wopi;
      drop table oc_richdocuments_assets;
      delete from oc_migrations where app='richdocuments';
    • reinstall the app
  10. SimplyCorbett commented on Apr 24, 2020

    @SimplyCorbett

    Can confirm, upgrading from 18.0.3 to 18.0.4 causes collabora to not open documents anymore.

  11. estan commented on Apr 24, 2020

    @estan

    I can confirm this problem, running Nextcloud 18.0.4, Collabora Online 3.5.3.

    The log shows:

    Doctrine\DBAL\Exception\InvalidFieldNameException: An exception occurred while executing 'INSERT INTO `richdocuments_wopi`(`fileid`,`owner_uid`,`editor_uid`,`version`,`canwrite`,`server_host`,`token`,`expiry`,`template_destination`,`hide_download`,`direct`,`is_remote_token`,`template_id`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)' with params [11, "admin", "admin", 0, true, "https:\/\/doc.xmine.eu\/", "vailWRjvthhoF05JIhOf5QVafn79gsm4", 1587763645, 0, false, false, false, 0]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'template_id' in 'field list'
    

    Here's occ migrations:status richdocuments and the MySQL table described:

    root@huygens:/mnt/vdb1/nextcloud-docker# docker exec -ti -u www-data nextcloud-docker_nextcloud_1 php occ migrations:status richdocuments
        >> App:                                                richdocuments
        >> Version Table Name:                                 migrations
        >> Migrations Namespace:                               OCA\Richdocuments\Migration
        >> Migrations Directory:                               /var/www/html/custom_apps/richdocuments/lib/Migration
        >> Previous Version:                                   2060Date20200302131958
        >> Current Version:                                    2060Date20200302132145
        >> Next Version:                                       Already at latest migration step
        >> Latest Version:                                     2060Date20200302132145
        >> Executed Migrations:                                2
        >> Executed Unavailable Migrations:                    2
        >> Available Migrations:                               2
        >> New Migrations:                                     2
        >> Pending Migrations:                                 None
    root@huygens:/mnt/vdb1/nextcloud-docker# docker exec -ti nextcloud-docker_db_1 mysql -u nextcloud -p nextcloud -e "DESCRIBE richdocuments_wopi"
    Enter password: 
    +----------------------+------------------+------+-----+-----------+----------------+
    | Field                | Type             | Null | Key | Default   | Extra          |
    +----------------------+------------------+------+-----+-----------+----------------+
    | id                   | int(10) unsigned | NO   | PRI | NULL      | auto_increment |
    | owner_uid            | varchar(64)      | YES  |     | NULL      |                |
    | editor_uid           | varchar(64)      | YES  |     | NULL      |                |
    | guest_displayname    | varchar(64)      | YES  |     | NULL      |                |
    | fileid               | int(11)          | NO   |     | NULL      |                |
    | version              | int(11)          | NO   |     | 0         |                |
    | canwrite             | tinyint(1)       | NO   |     | 0         |                |
    | server_host          | varchar(255)     | NO   |     | localhost |                |
    | token                | varchar(32)      | NO   | UNI |           |                |
    | expiry               | int(10) unsigned | YES  |     | NULL      |                |
    | template_destination | int(11)          | YES  |     | NULL      |                |
    | hide_download        | tinyint(1)       | NO   |     | 0         |                |
    | direct               | tinyint(1)       | NO   |     | 0         |                |
    | is_remote_token      | tinyint(1)       | NO   |     | 0         |                |
    | remote_server        | varchar(255)     | NO   |     |           |                |
    | remote_server_token  | varchar(32)      | NO   |     |           |                |
    | share                | varchar(64)      | YES  |     | NULL      |                |
    +----------------------+------------------+------+-----+-----------+----------------+
    root@huygens:/mnt/vdb1/nextcloud-docker#
    

    So as you can see, it thinks it has run all migrations, but the column has not been created.

    I unfortunately don't remember which exact Collabora Online app version I had before I upgraded.

    Please let me know how to proceed in this situation. Should I add the missing column manually? EDIT: Nevermind @juliushaertl, now I saw your instructions at #917 (comment) . They worked fine 👍 But I believe you forgot the oc_richdocuments_member table, that should also be dropped right?

  12. mhow2 commented on Apr 28, 2020

    @mhow2

    Same problem here ! Please could you post the official and complete fix ?

  13. oraclesod commented on Apr 29, 2020

    @oraclesod

    It would work if I uninstall, delete from the DB the tables oc_richdocuments_* and then install the app, right?

    Yes, but in addition you also need to clear the migrations for richdocuments, so it should be the following steps:

    • disable app
    • remove app folder
    • run the following sql statements:
      drop table oc_richdocuments_direct;
      drop table oc_richdocuments_wopi;
      drop table oc_richdocuments_assets;
      delete from oc_migrations where app='richdocuments';
    • reinstall the app

    This resolved it for me, thank you

  14. XUBIUM commented on May 4, 2020

    @XUBIUM
    Author

    Hello,
    I realize I never confirmed that the procedure also fixed the issue in my instance. Thanks Julius.

  15. MollyBe commented on May 10, 2020

    @MollyBe

    @foormea

    disable app:

    • Login to NextCloud as admin and go to your Apps page
    • Find " Collabora Online"
    • Disable and remove it

    remove app folder:

    • Log in to your server shell and access the NextCloud container with:
    • docker exec -it nextcloud /bin/bash
    • Now remove the app folder:
    • rm -rf /data/appdata*/richdocuments

    run the following sql statements:

    • Exit your NextCloud container and access your MariaDB container shell:
    • docker exec -it mariadb /bin/bash
    • Once in, you may need to provide your password to access your db:
    • mariadb -p and then enter the password.
    • Now you need to coose the db to edit:
    • mariadb use nextcloud
    • Now you can enter the following:
    • drop table oc_richdocuments_direct;
    • drop table oc_richdocuments_wopi;
    • drop table oc_richdocuments_assets;
    • delete from oc_migrations where app='richdocuments';

    Go back to your NextCloud App's page, and as admin reinstall the app - Collabora Online.

    I can confirm this works.

  16. estan commented on May 10, 2020

    @estan

    To add two small details to the instructions from @MollyBe (which are great!):

    1. The database tables may or may not have the oc_ prefix in their name. In my case they didn't (the database is exclusive to Nextcloud, so no prefix needed), so the tables were named just richdocuments_direct, richdocuments_wopi et.c

    2. Don't forget the oc_richdocuments_member table. This was left out in @juliushaertl's original instructions, but I believe it should be removed too.

  17. mhow2 commented on May 11, 2020

    @mhow2

    Thank you all ! I still have an innocent question : is the bug that triggers the current issue has been fixed ?

  18. arusa commented on Jul 2, 2020

    @arusa

    This even happened to a completely fresh install of the richdocuments app on nextcloud 18.0.4

    There must be something wrong with the migrations...

  19. DMW007 commented on Jul 11, 2020

    @DMW007

    Update: Was resolved using CLI

    Installing the app using the web ui as admin doesn't work (see the last section of this post). I disabled and uninstalled the app (which seems incomplete installed by the web ui) again and installed it using the occ cli:

    # docker exec -it --user www-data nextcloud_php bash
    www-data@e6bc9af4e688:~/html$ php occ app:install richdocuments
    richdocuments installed
    richdocuments enabled

    This was much faster and doesn't produce any DB errors. Now I need to open /index.php/settings/admin/richdocuments and just click "save". My collabora url was already present there, but it shows a connection error which was gone after re-saving (seems caused by the reinstall). Now it works well again :)

    Original Post

    I tried the provided instructions of reinstalling the app. But at the end after installing the app, I got the following error:

    An exception occurred while executing 'INSERT INTO oc_migrations (app,version) SELECT ?,? FROM oc_migrations WHERE app = ? AND version = ? HAVING COUNT(*) = 0' with params ["richdocuments", "2060Date20200302131958", "richdocuments", "2060Date20200302131958"]: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction

    In the logs are more details:

    [settings] Error: Doctrine\DBAL\Exception\LockWaitTimeoutException: An exception occurred while executing 'INSERT INTO `oc_migrations` (`app`,`version`) SELECT ?,? FROM `oc_migrations` WHERE `app` = ? AND `version` = ? HAVING COUNT(*) = 0' with params ["richdocuments", "2060Date20200302131958", "richdocuments", "2060Date20200302131958"]:
    
    SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction at <<closure>>
    
     0. /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 169
        Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException("An exception oc ... n", Doctrine\DBAL\Dr ... ]})
     1. /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 145
        Doctrine\DBAL\DBALException::wrapException(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "An exception oc ... n")
     2. /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php line 1063
        Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "INSERT INTO `oc ... 0", {1: "richdocumen ... "})
     3. /var/www/html/lib/private/DB/Connection.php line 216
        Doctrine\DBAL\Connection->executeUpdate("INSERT INTO `oc ... 0", ["richdocuments" ... "], [])
     4. /var/www/html/lib/private/DB/Adapter.php line 120
        OC\DB\Connection->executeUpdate("INSERT INTO `oc ... 0", ["richdocuments" ... "])
     5. /var/www/html/lib/private/DB/Connection.php line 257
        OC\DB\Adapter->insertIfNotExist("*PREFIX*migrations", {app: "richdocum ... "}, ["app","version"])
     6. /var/www/html/lib/private/DB/MigrationService.php line 291
        OC\DB\Connection->insertIfNotExist("*PREFIX*migrations", {app: "richdocum ... "})
     7. /var/www/html/lib/private/DB/MigrationService.php line 493
        OC\DB\MigrationService->markAsExecuted("2060Date20200302131958")
     8. /var/www/html/lib/private/DB/MigrationService.php line 411
        OC\DB\MigrationService->executeStep("2060Date20200302131958", false)
     9. /var/www/html/lib/private/Installer.php line 146
        OC\DB\MigrationService->migrate()
    10. /var/www/html/settings/Controller/AppSettingsController.php line 447
        OC\Installer->installApp("richdocuments")
    11. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 170
        OC\Settings\Controller\AppSettingsController->enableApps(["richdocuments"], [])
    12. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 99
        OC\AppFramework\Http\Dispatcher->executeController(OC\Settings\Cont ... {}, "enableApps")
    13. /var/www/html/lib/private/AppFramework/App.php line 126
        OC\AppFramework\Http\Dispatcher->dispatch(OC\Settings\Cont ... {}, "enableApps")
    14. /var/www/html/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
        OC\AppFramework\App::main("OC\\Settings\\C ... r", "enableApps", OC\AppFramework\ ... {}, {_route: "settin ... "})
    15. <<closure>>
        OC\AppFramework\Routing\RouteActionHandler->__invoke({_route: "settin ... "})
    16. /var/www/html/lib/private/Route/Router.php line 297
        undefinedundefinedcall_user_func(OC\AppFramework\ ... {}, {_route: "settin ... "})
    17. /var/www/html/lib/base.php line 997
        OC\Route\Router->match("/settings/apps/enable")
    18. /var/www/html/index.php line 42
        OC::handleRequest()
    
    POST /index.php/settings/apps/enable
    from 192.168.10.8 by admin-user at 2020-07-11T16:25:40+00:00
    

    Nextcloud 17.0.7 is installed.

  20. pierre-alain-b commented on Sep 13, 2020

    @pierre-alain-b

    I had exactly the issue described here on a NC. Maybe collabora was installed in the past (maybe in 2017 or something) on the instance. I had to do exactly what was mentioned above:

    • disable app
      
    • remove app folder
      
    • run the following sql statements:
      
    • drop table oc_richdocuments_direct;
      
    • drop table oc_richdocuments_wopi;
      
    • drop table oc_richdocuments_assets;
      
    • delete from oc_migrations where app='richdocuments';
      
    • reinstall the app
      

    Thanks @juliushaertl !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginfo neededFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions