Skip to content

Failed to update | Multiple primary key for oc_locks table #5139

Closed

Description

@mokkin

Aktualisiere ownCloud auf Version 5.0.12. Dies könnte eine Weile dauern.

Turned on maintenance mode

Failed to update database structure (MDB2 Error: unknown error, _doQuery: [Error message: Could not execute statement] [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] [Native code: 1068] [Native message: Multiple primary key defined] )

Das Update ist fehlgeschlagen. Bitte melden Sie dieses Problem an die ownCloud Community.

Apache 2.2.22
MYSQL 5.5
PHP 5.3.10
Ubuntu 12.04 x64

Activity

  1. XueSheng-GIT commented on Oct 4, 2013

    @XueSheng-GIT

    Looks like issue #999
    This post might help you: #999 (comment)

  2. mokkin commented on Nov 6, 2013

    @mokkin
    Author

    @XueSheng-GIT
    I've manually done those SQL-commands after upgrading to 5.0.13 I'll see it on the next update, if it works.
    Thx so far!

  3. exic commented on Nov 8, 2013

    @exic

    Same here on update to 5.0.12 and 5.0.13. Now I've as well run the commands after upgrading to 5.0.13. Is that all? No need to rerun some update procedure?

  4. karlitschek commented on Nov 10, 2013

    @karlitschek
    Contributor

    @DeepDiver1975 Any idea?

  5. Wikinaut commented on Nov 11, 2013

    @Wikinaut
    Contributor

    @karlitschek @DeepDiver1975

    see at the end of #999 (comment) :
    (I have no idea at the moment, if this helps)

    Update:
    
    Commands posted by ceri https://github.com/owncloud/core/issues/999#issuecomment-16778131 did solve the issue.
    

    Ceri's comment is #999 (comment) :

    Had the same issue here going from 5.0.3 to 5.0.5 using MySQL. Had to run in the following commands myself.
    
    ALTER TABLE `oc_locks` CHANGE `id` `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, drop primary key;
    ALTER TABLE oc_locks 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;  
    ALTER TABLE `oc_queuedtasks` CHANGE `id` `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, drop primary key; 
    ALTER TABLE `oc_vcategory` CHANGE `id` `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, drop primary key;
    
    

    OC Developers are asked to please better test the upgrade code - it is essential, that upgrading runs smoothly.

  6. VicDeo commented on Nov 11, 2013

    @VicDeo
    Contributor

    IMO preventive deletion of existing key with

          ALTER TABLE `oc_locks` CHANGE `id` `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, drop primary key;
    

    should help. But this is just a workaround, not a fix at all.

  7. karlitschek commented on Nov 11, 2013

    @karlitschek
    Contributor

    @DeepDiver1975 Do you know if we have changes the oc_locks table lately?

  8. DeepDiver1975 commented on Nov 11, 2013

    @DeepDiver1975
    Contributor

    @karlitschek there has been no database schema change from 5.0.12 to 5.0.13:
    v5.0.12...v5.0.13

  9. XueSheng-GIT commented on Nov 11, 2013

    @XueSheng-GIT

    I had this issue with updating from 5.0.5 to 5.0.6 (others reported this also with even older versions of owncloud).

    I did a fresh install of owncloud 5.0.x at that time, but started with a sqlite database. Later on I exported this database and imported it to mysql.

    Did others who are affected by this bug also start with sqlite and converted the database afterwards? Maybe that could be a reason.

  10. karlitschek commented on Nov 11, 2013

    @karlitschek
    Contributor

    @XueSheng-GIT O.K. It is possible that something went wrong here.

  11. DeepDiver1975 commented on Nov 11, 2013

    @DeepDiver1975
    Contributor

    @karlitschek the table schema did not change through out the whole 5.0.x lifecycle up to now.
    I suspect the root cause within the mbd2 schema migration - not much we can do from my understanding.

  12. mokkin commented on Nov 11, 2013

    @mokkin
    Author

    I have to add, I also started on OC 4 with SQLite and later during OC 5 I migrated to MySQL.

  13. Wikinaut commented on Nov 11, 2013

    @Wikinaut
    Contributor

    @XueSheng-GIT

    Did others who are affected by this bug also start with sqlite and converted the database afterwards? Maybe that could be a reason.

    Same for me: I have also to add that

    • I started with SQLite and
    • later I migrated to MySQL (some months ago) in OC 5.0.12

    using the steps described in

    with the Python script linked in there

    #! /usr/bin/env python
    
    import sys
    
    def main():
        print "SET sql_mode='NO_BACKSLASH_ESCAPES';"
        lines = sys.stdin.read().splitlines()
        for line in lines:
            processLine(line)
    
    def processLine(line):
        if (
            line.startswith("PRAGMA") or 
            line.startswith("BEGIN TRANSACTION;") or
            line.startswith("COMMIT;") or
            line.startswith("DELETE FROM sqlite_sequence;") or
            line.startswith("INSERT INTO \"sqlite_sequence\"")
           ):
            return
        line = line.replace("AUTOINCREMENT", "AUTO_INCREMENT")
        line = line.replace("DEFAULT 't'", "DEFAULT '1'")
        line = line.replace("DEFAULT 'f'", "DEFAULT '0'")
        line = line.replace(",'t'", ",'1'")
        line = line.replace(",'f'", ",'0'")
        in_string = False
        newLine = ''
        for c in line:
            if not in_string:
                if c == "'":
                    in_string = True
                elif c == '"':
                    newLine = newLine + '`'
                    continue
            elif c == "'":
                in_string = False
            newLine = newLine + c
        print newLine
    
    if __name__ == "__main__":
        main()
    

    Perhaps, the convertions made by script caused our trouble, perhaps because some INDEXes are now incorrect or missing ?

  14. exic commented on Nov 11, 2013

    @exic

    OK, that goes for me too. Started with sqlite on some OC 5 version and changed to mysql later.

  15. karlitschek commented on Nov 11, 2013

    @karlitschek
    Contributor

    OK. Seems to be clear that this is triggered by a broken way to migrate to a different database. Nothing we can do here beside providing a working howto in the future. Or even a database Migration script which might be tricky to do right as proven here.

  16. Wikinaut commented on Nov 11, 2013

    @Wikinaut
    Contributor

    @karlitschek

    Dear Frank, perhaps you as expert can find

    • and please post

    what database or index conversion has been missing in the Python code (sqlite-to-MySQL converter) above #5139 (comment) .

    As we all can see in this thread and other filed issues, quite a lot of users suffer from that (alleged) conversion-related problem.

  17. karlitschek commented on Nov 12, 2013

    @karlitschek
    Contributor

    Sorry. But there is no working, tested and documented solution for this yet. This has to be developed. Contributions are welcome.

  18. bantu commented on Nov 16, 2013

    @bantu

    @DeepDiver1975 Remove oc6 tag? See #5139 (comment)

  19. karlitschek commented on Nov 17, 2013

    @karlitschek
    Contributor

    Yes. I removed it

  20. karlitschek commented on Nov 29, 2013

    @karlitschek
    Contributor

    duplicate of #4085

  21. locked as resolved and limited conversation to collaborators on Aug 19, 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