Skip to content

Error while upgrading from 4.5.4 to 4.5.5: Failed to update database structure #999

Closed

Description

@radoeka

Just upgraded from 4.5.4 to 4.5.5 and run into the same as mentioned in:
#664 (upgrade from 4.5.2 to 4.5.3)
Unfortunately I did not make a backup of the 4.5.4 database. As such I can not redo the upgrade. Perhaps I remember to this with the next upgrade.

The log file contains:

{"app":"core","message":"Failed to update database structure (MDB2 Error: unknown error, _doQuery: [Error message: Could not execute statement]\n[Last executed query: SELECT sql FROM sqlite_master WHERE type='table' AND name='oc_appconfig']\n[Native code: 5]\n[Native message: database is locked]\n)","level":4,"time":1356087810}

On the GUI it is:

Fatal    core    Failed to update database structure (MDB2 Error: unknown error, _doQuery: [Error message: Could not execute statement] [Last executed query: SELECT sql FROM sqlite_master WHERE type='table' AND name='oc_appconfig'] [Native code: 5] [Native message: database is locked] )  December 21, 2012, 12:03

Downgrading the version setting in config/config.php and re-visiting the start page does not result in the error.

Perhaps this problems happens as I just switched on the machine and did not visit the owncloud instance before. Perhaps it takes some time to load libraries or something like that???

Activity

  1. anti-pencil commented on Jan 29, 2013

    @anti-pencil

    I had an error similar to this after updating from 4.5.5 - 4.5.6...

    Failed to update database structure (MDB2 Error: unknown error, _doQuery: [Error message: Could not execute statement] [Last executed query: ALTER TABLE `oc_groups` ADD PRIMARY KEY (`gid`)] [Native code: 1068] [Native message: Multiple primary key defined] )
    

    I only saw the message appear once when logged into online interface as Admin user under the Admin tab as a FATAL warning. After rebooting Apache2 a couple of times, I have not seen the message. Services appear fully functional at this time.

  2. radoeka commented on Feb 10, 2013

    @radoeka
    Author

    Related: #1036

  3. simlan123 commented on Feb 21, 2013

    @simlan123

    Found something similar with the upgrade from 4.5.6 --> 4.5.7 (Internal numbering: 4.90.7 --> 4.90.8 )

    System Info:
    OS: Ubuntu 12.04.1 LTS (server)
    Database: MySql 5.5.29-0

    Log output:

    {"app":"core","message":"starting upgrade from 4.90.7 to 4.90.8","level":0,"time":1361440266}
    {"app":"core","message":"Failed to update database structure (MDB2 Error: unknown error, _doQuery: [Error 
    message: Could not execute statement]\n[Last executed query: ALTER TABLE `oc_locks` CHANGE `id` `id` INT 
    UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, CHANGE `timeout` `timeout` INT UNSIGNED DEFAULT 0, CHANGE `created` 
    `created` BIGINT DEFAULT 0, CHANGE `scope` `scope` TINYINT DEFAULT 0, 
    CHANGE `depth` `depth` TINYINT DEFAULT 0]\n[Native code: 1068]\n[Native message: Multiple primary key 
    defined]\n)","level":4,"time":1361440266}
    

    Visiting the instance gives the error: Unable to upgrade the database (Or soemthing like that)

    Setting installed version from 4.90.7 to 4.90.8 in config.php manually "resolves" the problem. It seems to work rather good but I have to do additonal testing.

    How could I test if the failed alter table to oc_locks affects my users ?

  4. Captain-Rage commented on Feb 26, 2013

    @Captain-Rage

    Had the same problem after upgrading to 4.5.7 from 4.5.6 (and to 4.5.6 from 4.5.5, as I recall). Editing config.php solved it for me!
    My machine is using SQlite and lighttpd.

  5. BernhardPosselt commented on Feb 26, 2013

    @BernhardPosselt
    Contributor

    I think the general consensus is to migrate to doctrine as soon as possible.

    @bartv2 if you need help tell me.

  6. karlitschek commented on Feb 26, 2013

    @karlitschek
    Contributor

    Yes. But please do only the schema piece for now and not the full ORM piece.
    It is important that we have a fully working version in a branch before we merge. All apps have to be migrated and tested. I also want to have a performance test to see how much slower the new code is.

  7. bartv2 commented on Feb 26, 2013

    @bartv2
    Contributor

    @karlitschek it is only the replacement of the current db layer, no ORM yet ;)

  8. bartv2 commented on Feb 26, 2013

    @bartv2
    Contributor

    I got the error 'database is locked' also with the doctrine code. The problem is the caching of prepared statements, sqlite keeps the connection open when there are still statements around. I think we should disable the caching for sqlite. @karlitschek @icewind1991 What do you think?

  9. karlitschek commented on Feb 26, 2013

    @karlitschek
    Contributor
  10. karlitschek commented on Feb 26, 2013

    @karlitschek
    Contributor

    @bartv2 I haven't looked into the db locking issue yet. I have no idea what the best practice is if you have other php/apache processes handing around with open connections. Perhaps it's worth looking into other PHP applications to check how they do it.

  11. BernhardPosselt commented on Feb 26, 2013

    @BernhardPosselt
    Contributor

    Typical SQLite problem, I'd actively discourage users from using it.

  12. DeepDiver1975 commented on Feb 26, 2013

    @DeepDiver1975
    Contributor

    .... I'd actively discourage users from using it.

    Nice - where is the solution? Come on - comments like that are of zero help.

  13. BernhardPosselt commented on Feb 26, 2013

    @BernhardPosselt
    Contributor

    What do you mean by solution? PR where it says not recommended when you choose SQlite on the install page?

    I dont know how others think about it yet, thats why I only stated my opinion. Also I dont think this can be solved, its an SQLite specific issue that I ran into in my own projects.

  14. radoeka commented on Feb 26, 2013

    @radoeka
    Author

    sqlite is really nice to quickly try out owncloud. It is very easy to setup. Once a full blown installation is needed one can use one of the bigger database engines.

  15. BernhardPosselt commented on Feb 26, 2013

    @BernhardPosselt
    Contributor

    Well sure its nice because its fast and easy. But its not intended to be used that way in production. If someone wants to use sqlite in production then he shouldnt complain about broken dbs.

  16. 29 remaining items

  17. butonic commented on Jan 10, 2014

    @butonic
    Contributor

    indeed. dumping a sqlite3 db produces this line for oc_locks:

    CREATE TABLE oc_locks2 (id INTEGER PRIMARY KEY AUTOINCREMENT, userid VARCHAR(64), owner VARCHAR(100), timeout INTEGER UNSIGNED DEFAULT 0, created BIGINT DEFAULT 0, token VARCHAR(100), scope SMALLINT DEFAULT 0, depth SMALLINT DEFAULT 0, uri LONGTEXT);

    the sqlite3-to-mysql.py script turns it into

    CREATE TABLE oc_locks (id INTEGER PRIMARY KEY AUTO_INCREMENT, userid VARCHAR(64), owner VARCHAR(100), timeout INTEGER UNSIGNED DEFAULT 0, created BIGINT DEFAULT 0, token VARCHAR(100), scope SMALLINT DEFAULT 0, depth SMALLINT DEFAULT 0, uri LONGTEXT);

    which in turn produces a table like this:

    mysql> describe oc_locks
        -> ;
    +---------+------------------+------+-----+---------+----------------+
    | Field   | Type             | Null | Key | Default | Extra          |
    +---------+------------------+------+-----+---------+----------------+
    | id      | int(11)          | NO   | PRI | NULL    | auto_increment |
    | userid  | varchar(64)      | YES  |     | NULL    |                |
    | owner   | varchar(100)     | YES  |     | NULL    |                |
    | timeout | int(10) unsigned | YES  |     | 0       |                |
    | created | bigint(20)       | YES  |     | 0       |                |
    | token   | varchar(100)     | YES  |     | NULL    |                |
    | scope   | smallint(6)      | YES  |     | 0       |                |
    | depth   | smallint(6)      | YES  |     | 0       |                |
    | uri     | longtext         | YES  |     | NULL    |                |
    +---------+------------------+------+-----+---------+----------------+
    

    If @doomi @etam @simlan123 or @radoeka could respond wether or not they migrated from sqlite to mysql, we could finally have found the root cause of this.

    @karlitschek we could check if the id columns are defined as int(11) and log a warning in the db?

  18. XueSheng-GIT commented on Jan 10, 2014

    @XueSheng-GIT

    Same discussion as #5139.
    Root cause was migration of sqlite to mysql.

  19. radoeka commented on Jan 10, 2014

    @radoeka
    Author

    I always used sqlite3.

  20. radoeka commented on Jan 10, 2014

    @radoeka
    Author

    I've not encountered this problem for a long time (perhaps not since I reported the issue).

  21. DeepDiver1975 commented on Feb 6, 2014

    @DeepDiver1975
    Contributor

    @karlitschek @icewind1991 this issue contains a lot of information regarding failed database migrations and potential steps regarding the database repair operation

  22. karlitschek commented on Jul 4, 2014

    @karlitschek
    Contributor

    @PVince81 Can you go through this issue and check if everything should be covered by our new db migration test and repair scripts? Thanks

  23. PVince81 commented on Jul 4, 2014

    @PVince81
    Contributor

    @icewind1991 could help as well.

  24. PVince81 commented on Jul 4, 2014

    @PVince81
    Contributor

    He knows more about checkMigrate than I do since he wrote it.

    The repair scripts part at the moment only fixes mimetypes for office files.

  25. PVince81 commented on Aug 19, 2014

    @PVince81
    Contributor

    From reading through the comments, it seems that one issue is the "Database is locked" issue from SQLite, which was addressed already multiple times and isn't related to the repair routine.

    The other outstanding issue is the upgrade of the oc_locks (what's this table for?) table with primary key issues. With the new checkMigrate such cases should be caught during upgrade simulation.

  26. locked as resolved and limited conversation to collaborators on Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions