Asunto "Upgrading Ilias from 5.4 to 7.x, error during database update"

Pestañas

  • borrados
    borrados | 11. Oct 2021, 10:52
    Edición activa: 11. Oct 2021, 11:20 - por borrados
    Upgrading Ilias from 5.4 to 7.x, error during database update
    I want to update our Ilias from 5.4 to 7.x. I started from the latest 5.4 with current database updates going to newsest release_6. The setup GUI crashes at database step #5526. I cannot see any useful error information displayed in the webfront nor in the ilias.log. The specific update contains:

    <#5526> <?php $ilDB->addPrimaryKey("book_obj_use_book", array("obj_id", "book_obj_id")); ?>

    What could be the reason and how do Ifix this?

    edit:

    The error seems to be as expected a multiple primary key error. But why is this the case?

    Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary key defined in /srv/ilias/Services/Database/classes/PDO/Manager/class.ilDBPdoManager.php:155 Stack trace: #0 /srv/ilias/Services/Database/classes/PDO/Manager/class.ilDBPdoManager.php(155): PDO->exec('ALTER TABLE `bo...') #1 /srv/ilias/Services/Database/classes/PDO/class.ilDBPdo.php(354): ilDBPdoManager->createConstraint('`book_obj_use_b...', '`PRIMARY_idx`', Array) #2 /srv/ilias/Services/Database/classes/class.ilDBUpdate.php(496) : eval()'d code(1): ilDBPdo->addPrimaryKey('book_obj_use_bo...', Array) #3 /srv/ilias/Services/Database/classes/class.ilDBUpdate.php(496): eval() #4 /srv/ilias/Services/Database/classes/class.ilDBUpdate.php(363): ilDBUpdate->applyUpdateNr(5526) #5 /srv/ilias/setup/classes/class.ilSetupGUI.php(2690): ilDBUpdate->applyUpdate(5649) #6 /srv/ilias/setup/classes/class.ilSetupGUI.php(439): ilSetupGUI->updateDatabase() #7 /srv/ilias/setup/classes/class.ilSetupGUI.php(275): ilSetupGUI->cmdClient() in /srv/ilias/Services/Database/classes/PDO/Manager/class.ilDBPdoManager.php on line 155

  • utesche
    utesche | utesche | 11. Oct 2021, 11:21
    Edición activa: 11. Oct 2021, 11:25 - por utesche | utesche
    Re: Upgrading Ilias from 5.4 to 7.x, error during database update
    Hi greyfox,

    (A)
    if it was the very first attempt to process step #5526:  I can't image what went wrong.
    You may try to declare a primary by hand, just for diagnosis:

    SQL>  alter table your_ilias_database.book_obj_use_book add constraint xyz primary key (obj_id, book_obj_id);

    This should work, if not: you should get an idea of what is wrong.
    *IF* it works, you should remove this primary key - see below in (B).

    (B)
    If it was NOT the very first attempt,  the primary key may exists already => then step #5526 (if executed again) gets error 1068:
    ERROR 1068 (42000): Multiple primary key defined

    This could happen if the update process war disrupted anyhow AFTER the execution of the alter statement, but BEFORE the successful execution of this very step could be written to the settings.

    I guess:  step 5526 is the nominated next step to be done actually?
    If so, check the existance of the primary key with:

    SQL>  show index on your_ilias_database.book_obj_use_book;
    You may get (positively):

    +-------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
    | Table             | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
    +-------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
    | book_obj_use_book |          0 | PRIMARY  |            1 | obj_id      | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
    | book_obj_use_book |          0 | PRIMARY  |            2 | book_ref_id | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
    +-------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
    2 rows in set (0.000 sec)

    Now you can do either -

    drop the primary key:
    SQL>  alter table your_ilias_database.book_obj_use_book drop primary key;

    or -

    step over to next step (#5527) by modifying the settings:
    SQL> update your_ilias_database.settings set value = '5527' where module = 'common' and keyword = 'db_version' and value = '5526';

    wbr
  • borrados
    borrados | 11. Oct 2021, 13:49
    Re (2): Upgrading Ilias from 5.4 to 7.x, error during database update
    Thank you very much! Your comments helped me to resolve the issue. It was indeed a not completely resettet database from a previous attempt.