core icon indicating copy to clipboard operation
core copied to clipboard

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

Open radoeka opened this issue 13 years ago • 54 comments

Just upgraded from 4.5.4 to 4.5.5 and run into the same as mentioned in: https://github.com/owncloud/core/issues/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???

radoeka avatar Dec 21 '12 11:12 radoeka

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.

anti-pencil avatar Jan 29 '13 23:01 anti-pencil

Related: #1036

radoeka avatar Feb 10 '13 19:02 radoeka

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 ?

simlan123 avatar Feb 21 '13 10:02 simlan123

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.

Captain-Rage avatar Feb 26 '13 07:02 Captain-Rage

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

@bartv2 if you need help tell me.

BernhardPosselt avatar Feb 26 '13 09:02 BernhardPosselt

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.

karlitschek avatar Feb 26 '13 09:02 karlitschek

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

bartv2 avatar Feb 26 '13 12:02 bartv2

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?

bartv2 avatar Feb 26 '13 12:02 bartv2

@bartv2 ;-)

karlitschek avatar Feb 26 '13 13:02 karlitschek

@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.

karlitschek avatar Feb 26 '13 13:02 karlitschek

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

BernhardPosselt avatar Feb 26 '13 13:02 BernhardPosselt

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

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

DeepDiver1975 avatar Feb 26 '13 13:02 DeepDiver1975

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.

BernhardPosselt avatar Feb 26 '13 14:02 BernhardPosselt

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.

radoeka avatar Feb 26 '13 16:02 radoeka

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.

BernhardPosselt avatar Feb 26 '13 16:02 BernhardPosselt

But its not intended to be used that way in production

This is a wrong assumption form my point of view. ownCloud is designed to run in a simple and stupid web space even without DBMS. This is the use case for sqlite. In addition sqlite is of course use in productive environments (e.g. Firefox, Android and many more)

DeepDiver1975 avatar Feb 26 '13 16:02 DeepDiver1975

In addition sqlite is of course use in productive environments (e.g. Firefox, Android and many more)

Well this is true for desktop apps with a single user. The problem is that its possible to get into Deadlocks (db is locked and cant be unlocked)

BernhardPosselt avatar Feb 26 '13 17:02 BernhardPosselt

Don't fight guys :-) We support und will keep on supporting SQLite. We need a solution for the locking issue but I'm sure this can be fixed somehow. Other PHP application can do this too. :-)

karlitschek avatar Feb 26 '13 17:02 karlitschek

Since the upgrade to the current version (4.5.7) is impossible and leaves you with a broken db, shouldn't there be at least a hint on the download page, to prevent people from upgrading?

benjamin-garn avatar Feb 28 '13 15:02 benjamin-garn

@benjamin-garn This appears to be limited to a very few ownCloud users. Is there additional information you can provide?

MTGap avatar Mar 02 '13 19:03 MTGap