Skip to content

Update from 8.2.2 to 9.0.0-1.1 failed - Doctrine\DBAL\Exception\TableExistsException Table 'oc_gallery_sharing' already exists #22993

Closed

Description

@HelFANS

Steps to reproduce

  1. apt-get dist-upgrade successfully
  2. Start updater in webbrowser
  3. Update will abort with
    Doctrine\DBAL\Exception\TableExistsException: An exception occurred while executing 'CREATE TABLE oc_gallery_sharing (token VARCHAR(64) NOT NULL, gallery_id INT DEFAULT 0 NOT NULL, recursive SMALLINT NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin ENGINE = InnoDB': SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'oc_gallery_sharing' already exists

Expected behaviour

Updater should run completely

Actual behaviour

The updater will stop with the error:
Doctrine\DBAL\Exception\TableExistsException: An exception occurred while executing 'CREATE TABLE oc_gallery_sharing (token VARCHAR(64) NOT NULL, gallery_id INT DEFAULT 0 NOT NULL, recursive SMALLINT NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin ENGINE = InnoDB': SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'oc_gallery_sharing' already exists

Server configuration

Operating system:
Ubuntu 14.04 LTS

Web server:
Server version: Apache/2.4.7 (Ubuntu)

Database:
mysql Ver 14.14 Distrib 5.5.47, for debian-linux-gnu (x86_64) using readline 6.3

PHP version:
PHP 5.5.9-1ubuntu4.14

ownCloud version: (see ownCloud admin page)
8.2.2
Updated from an older ownCloud or fresh install:
updated from 8.2.2

Where did you install ownCloud from:
/etc/apt/sources.list.d/owncloud.list
deb http://download.owncloud.org/download/repositories/stable/Ubuntu_14.04/ /

Signing status (ownCloud 9.0 and above):

List of activated apps:
When starting the upgrade, all apps are disabled.

After the failed update the system was set back to the existing snapshot.

The content of config/config.php:

If you have access to your command line run e.g.:
sudo -u www-data php occ config:list system
from within your ownCloud installation folder

or 

Insert your config.php content here
(Without the database password, passwordsalt and secret)

Are you using external storage, if yes which one: local/smb/sftp/...

Are you using encryption: yes/no

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...

LDAP configuration (delete this part if not used)

With access to your command line run e.g.:
sudo -u www-data php occ ldap:show-config
from within your ownCloud installation folder

Without access to your command line download the data/owncloud.db to your local
computer or access your SQL server remotely and run the select query:
SELECT * FROM `oc_appconfig` WHERE `appid` = 'user_ldap';


Eventually replace sensitive data as the name/IP-address of your LDAP server or groups.

Client configuration

Browser:

Operating system:

Logs

Web server error log

Insert your webserver log here

ownCloud log (data/owncloud.log)

Insert your ownCloud log here

Browser log

Insert your browser log here, this could for example include:

a) The javascript console log
b) The network log 
c) ...

Activity

  1. LukasReschke commented on Mar 9, 2016

    @LukasReschke
    Contributor

    Seems also like #22968.

    cc @nickvergessen

  2. added this to the milestone on Mar 9, 2016
  3. nickvergessen commented on Mar 9, 2016

    @nickvergessen
    Contributor

    Please post the list of apps before the update.

  4. HelFANS commented on Mar 9, 2016

    @HelFANS
    Author

    sudo -u www-data php occ app:list
    Enabled:

    • activity: 2.1.3
    • files: 1.2.0
    • files_mv: 0.8.1a
    • files_pdfviewer: 0.7
    • files_sharing: 0.7.0
    • files_texteditor: 2.0
    • files_trashbin: 0.7.0
    • files_versions: 1.1.0
    • files_videoviewer: 0.1.3
    • firstrunwizard: 1.1
    • gallery: 14.2.0
    • ocusagecharts: 2
    • search_lucene: 0.6.0
    • templateeditor: 0.1

    Disabled:

    • _calendar
    • _contacts
    • appframework
    • encryption
    • external
    • files_embeddedvideo
    • files_external
    • files_tree
    • fluxx_compensator
    • gallery-backup
    • mozilla_sync
    • notes
    • notifications
    • provisioning_api
    • user_external
    • user_ldap
    • videos

    but I have disabled all apps before the update.
    sudo -u www-data php occ app:disable activity
    sudo -u www-data php occ app:disable files
    sudo -u www-data php occ app:disable files_mv
    sudo -u www-data php occ app:disable files_pdfviewer
    sudo -u www-data php occ app:disable files_sharing
    sudo -u www-data php occ app:disable files_texteditor
    sudo -u www-data php occ app:disable files_trashbin
    sudo -u www-data php occ app:disable files_versions
    sudo -u www-data php occ app:disable files_videoviewer
    sudo -u www-data php occ app:disable firstrunwizard
    sudo -u www-data php occ app:disable gallery
    sudo -u www-data php occ app:disable ocusagecharts
    sudo -u www-data php occ app:disable search_lucene
    sudo -u www-data php occ app:disable templateeditor

  5. joni1993 commented on Mar 9, 2016

    @joni1993

    Another error that occurred while upgrading to 9.0.0 from 8.2.3.

    Doctrine\DBAL\Exception\TableExistsException: An exception occurred while executing 'CREATE TABLE `oc_clndr_objects` (`id` INT UNSIGNED AUTO_INCREMENT NOT NULL, `calendarid` INT UNSIGNED DEFAULT 0 NOT NULL, `objecttype` VARCHAR(40) DEFAULT '' NOT NULL, `startdate` DATETIME DEFAULT '1970-01-01 00:00:00', `enddate` DATETIME DEFAULT '1970-01-01 00:00:00', `repeating` INT DEFAULT 0, `summary` VARCHAR(255) DEFAULT NULL, `calendardata` LONGTEXT DEFAULT NULL, `uri` VARCHAR(255) DEFAULT NULL, `lastmodified` INT DEFAULT 0, PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin ENGINE = InnoDB':
    
    SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'oc_clndr_objects' already exists
    

    Ubuntu 15.04
    nginx
    MariaDB

    //Fixed: Removed an old copy of the calendar plugin in the apps directory which caused this problem. Interestingly that app wasn't even enabled but still tried to recreate its tables when updating oc. Shouldn't disabled apps don't do anything even when upgrading oc?

  6. Mattoje commented on Mar 9, 2016

    @Mattoje

    the same goes also for postgresql
    Doctrine\DBAL\Exception\TableExistsException: An exception occurred while executing 'CREATE TABLE "oc_activity" ("activity_id" SERIAL NOT NULL, "timestamp" INT DEFAULT 0 NOT NULL, "priority" INT DEFAULT 0 NOT NULL, "type" VARCHAR(255) DEFAULT NULL, "user" VARCHAR(64) DEFAULT NULL, "affecteduser" VARCHAR(64) NOT NULL, "app" VARCHAR(255) NOT NULL, "subject" VARCHAR(255) NOT NULL, "subjectparams" VARCHAR(4000) NOT NULL, "message" VARCHAR(255) DEFAULT NULL, "messageparams" VARCHAR(4000) DEFAULT NULL, "file" VARCHAR(4000) DEFAULT NULL, "link" VARCHAR(4000) DEFAULT NULL, "object_type" VARCHAR(255) DEFAULT NULL, "object_id" INT DEFAULT 0 NOT NULL, PRIMARY KEY("activity_id"))':

    SQLSTATE[42P07]: Duplicate table: 7 ERROR: relation "oc_activity" already exists
    Update failed

  7. vb0 commented on Mar 9, 2016

    @vb0

    Ubuntu 14.04.4 LTS, [edited] sqlite3

    I'm getting:

    Doctrine\DBAL\Exception\TableExistsException: An exception occurred while executing 'CREATE TABLE "oc_trusted_servers" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "url" VARCHAR(512) NOT NULL, "url_hash" VARCHAR(255) DEFAULT '' NOT NULL, "token" VARCHAR(128) DEFAULT NULL, "shared_secret" VARCHAR(256) DEFAULT NULL, "status" INTEGER DEFAULT 2 NOT NULL, "sync_token" VARCHAR(512) DEFAULT NULL)':

    SQLSTATE[HY000]: General error: 1 table "oc_trusted_servers" already exists
    Update failed

  8. Farfetch42 commented on Mar 10, 2016

    @Farfetch42

    Sorry posted: #23122 - Then found this thread.

    I'm also receiving this:

    `Doctrine\DBAL\Exception\TableExistsException: An exception occurred while executing 'CREATE TABLE "oc_trusted_servers" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "url" VARCHAR(512) NOT NULL, "url_hash" VARCHAR(255) DEFAULT '' NOT NULL, "token" VARCHAR(128) DEFAULT NULL, "shared_secret" VARCHAR(256) DEFAULT NULL, "status" INTEGER DEFAULT 2 NOT NULL, "sync_token" VARCHAR(512) DEFAULT NULL)':

    SQLSTATE[HY000]: General error: 1 table "oc_trusted_servers" already exists`

    Ubuntu 14.04 - Apache 2.4.7 - MySQL 14.14 - PHP 5.5.9

  9. nivoliev commented on Mar 10, 2016

    @nivoliev

    With some help, I finally got it working : after checking the differences between a backup of the database before the upgrade and its state when the error occured, the table is created by the update. After iteratively dropping the problematic tables in the database, and restarting the update, it finally ended successfully.

  10. 33 remaining items

  11. vb0 commented on Mar 17, 2016

    @vb0

    I did not restore from a backup but I think I did upgrade twice from command line (well, I tried many times but I have done one before the table exists problem). I ignored the first run because it seemed to do nothing, unfortunately I really can't remember what happened there. Where should the log be for this upgrade?

  12. nivoliev commented on Mar 17, 2016

    @nivoliev

    I can confirm in my case that the problem was due to an error in a previous upgrade attempt. The error message was that of #23013. Since the proposed solution was to restart the upgrade, that's what I did. I am using the basic sqlite as well, and the data directory containing the database is a symbolic link to a folder on another volume. This is probably the cause of the first upgrade failure. I believe the database was then left in a mixed state, and the second upgrade wasn't able to recover from this state. I believe that during the first upgrade attempt, the migration test passed, and then the real database migration failed because of the IO error.

  13. PVince81 commented on Mar 17, 2016

    @PVince81
    Contributor

    To check whether you ran the same upgrade several times, have a look at "owncloud.log", there should be entries that look like "Starting upgrade from version XXX to YYY" (something like this, not the exact text). You can check whether the version numbers in these messages are the same several times.

  14. BernieO commented on Mar 17, 2016

    @BernieO

    To me it happened with the first upgrade attempt. Excerpt of my owncloud.log:

    
    {main}\",\"File\":\"\\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/3rdparty\\\/sabre\\\/vobject\\\/lib\\\/Parser\\\/MimeDir.php\",\"Line\":253}","level":4,"time":"2016-03-10T18:26:53+01:00"}
    {"reqId":"S1jYE7AKOXHS48iQAKBz","remoteAddr":"192.168.1.30","app":"PHP","message":"Undefined index: addressBookId at \/usr\/share\/nginx\/www\/owncloud\/apps\/contacts\/lib\/hooks.php#109","level":3,"time":"2016-03-11T12:52:06+01:00"}
    {"reqId":"jIzDINfNAQEVCmMoGgNe","remoteAddr":"","app":"core","message":"starting upgrade from 8.2.3.2 to 9.0.0.19","level":0,"time":"2016-03-12T05:56:33+00:00","method":"--","url":"--"}
    {"reqId":"jIzDINfNAQEVCmMoGgNe","remoteAddr":"","app":"PHP","message":"file_put_contents(\/usr\/share\/nginx\/ownclouddata\/.htaccess): failed to open stream: Permission denied at \/usr\/share\/nginx\/www\/owncloud\/lib\/private\/setup.php#458","level":3,"time":"2016-03-12T05:56:33+00:00","method":"--","url":"--"}
    {"reqId":"jIzDINfNAQEVCmMoGgNe","remoteAddr":"","app":"core","message":"Exception: {\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\TableExistsException\",\"Message\":\"An exception occurred while executing 'CREATE TABLE `oc_activity` (`activity_id` INT AUTO_INCREMENT NOT NULL, `timestamp` INT DEFAULT 0 NOT NULL, `priority` INT DEFAULT 0 NOT NULL, `type` VARCHAR(255) DEFAULT NULL, `user` VARCHAR(64) DEFAULT NULL, `affecteduser` VARCHAR(64) NOT NULL, `app` VARCHAR(255) NOT NULL, `subject` VARCHAR(255) NOT NULL, `subjectparams` VARCHAR(4000) NOT NULL, `message` VARCHAR(255) DEFAULT NULL, `messageparams` VARCHAR(4000) DEFAULT NULL, `file` VARCHAR(4000) DEFAULT NULL, `link` VARCHAR(4000) DEFAULT NULL, `object_type` VARCHAR(255) DEFAULT NULL, `object_id` INT DEFAULT 0 NOT NULL, INDEX activity_time (`timestamp`), INDEX activity_user_time (`affecteduser`, `timestamp`), INDEX activity_filter_by (`affecteduser`, `user`, `timestamp`), INDEX activity_filter_app (`affecteduser`, `app`, `timestamp`), PRIMARY KEY(`activity_id`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin ENGINE = InnoDB':\\n\\nSQLSTATE[42S01]: Base table or view already exists: 1050 Table 'oc_activity' already exists\",\"Code\":0,\"Trace\":\"#0 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/DBALException.php(116): Doctrine\\\\DBAL\\\\Driver\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Connection.php(945): Doctrine\\\\DBAL\\\\DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOMySql\\\\Driver), Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException), 'CREATE TABLE `o...')\\n#2 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/lib\\\/private\\\/db\\\/mdb2schemamanager.php(167): Doctrine\\\\DBAL\\\\Connection->query('CREATE TABLE `o...')\\n#3 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/lib\\\/private\\\/db\\\/mdb2schemamanager.php(70): OC\\\\DB\\\\MDB2SchemaManager->executeSchemaChange(Object(Doctrine\\\\DBAL\\\\Schema\\\\Schema))\\n#4 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/lib\\\/private\\\/db.php(172): OC\\\\DB\\\\MDB2SchemaManager->createDbFromStructure('\\\/usr\\\/share\\\/ngin...')\\n#5 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/lib\\\/private\\\/installer.php(567): OC_DB::createDbFromStructure('\\\/usr\\\/share\\\/ngin...')\\n#6 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/lib\\\/private\\\/installer.php(546): OC_Installer::installShippedApp('activity')\\n#7 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/lib\\\/private\\\/updater.php(336): OC_Installer::installShippedApps()\\n#8 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/lib\\\/private\\\/updater.php(215): OC\\\\Updater->doUpgrade('9.0.0.19', '8.2.3.2')\\n#9 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/core\\\/command\\\/upgrade.php(225): OC\\\\Updater->upgrade()\\n#10 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/3rdparty\\\/symfony\\\/console\\\/Command\\\/Command.php(259): OC\\\\Core\\\\Command\\\\Upgrade->execute(Object(Symfony\\\\Component\\\\Console\\\\Input\\\\ArgvInput), Object(Symfony\\\\Component\\\\Console\\\\Output\\\\ConsoleOutput))\\n#11 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/3rdparty\\\/symfony\\\/console\\\/Application.php(840): Symfony\\\\Component\\\\Console\\\\Command\\\\Command->run(Object(Symfony\\\\Component\\\\Console\\\\Input\\\\ArgvInput), Object(Symfony\\\\Component\\\\Console\\\\Output\\\\ConsoleOutput))\\n#12 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/3rdparty\\\/symfony\\\/console\\\/Application.php(192): Symfony\\\\Component\\\\Console\\\\Application->doRunCommand(Object(OC\\\\Core\\\\Command\\\\Upgrade), Object(Symfony\\\\Component\\\\Console\\\\Input\\\\ArgvInput), Object(Symfony\\\\Component\\\\Console\\\\Output\\\\ConsoleOutput))\\n#13 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/3rdparty\\\/symfony\\\/console\\\/Application.php(123): Symfony\\\\Component\\\\Console\\\\Application->doRun(Object(Symfony\\\\Component\\\\Console\\\\Input\\\\ArgvInput), Object(Symfony\\\\Component\\\\Console\\\\Output\\\\ConsoleOutput))\\n#14 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/lib\\\/private\\\/console\\\/application.php(145): Symfony\\\\Component\\\\Console\\\\Application->run(NULL, NULL)\\n#15 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/console.php(88): OC\\\\Console\\\\Application->run()\\n#16 \\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/occ(11): require_once('\\\/usr\\\/share\\\/ngin...')\\n#17 {main}\",\"File\":\"\\\/usr\\\/share\\\/nginx\\\/www\\\/owncloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/AbstractMySQLDriver.php\",\"Line\":49}","level":3,"time":"2016-03-12T05:56:58+00:00","method":"--","url":"--"}
    
  15. BernieO commented on Mar 17, 2016

    @BernieO

    P.S.: I did upgrade 2 days before from 8.2.2 to 8.2.3 - maybe the table causing issues was created then?

  16. murzz commented on Mar 19, 2016

    @murzz

    @PVince81 yes this error happens to me after I run occ upgrade second time. First time it failed with General error: 10 disk I/O error. Then upgrade starts failing with General error: 1 table "oc_notifications" already exists.
    Removing oc_notifications table from my sqlite database was not of help.
    After removing folder apps/notifications upgrade completed without errors.

  17. nickvergessen commented on Mar 21, 2016

    @nickvergessen
    Contributor

    Well we can't help with the disk error. But as said already:
    Before doing a second attempt of the update you need to drop your database and recreate it from a backup, to make sure that no new table/columns are there.

  18. modified the milestones: , on Mar 22, 2016
  19. lock commented on Aug 5, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions