Menu

3.0 -> 3.2 database error

2024-11-27
2024-12-02
  • Jacques Dancause

    Hey there! Hope you're well.

    What we've done
    We're in the process of updating our prod instance to 3.2, and we've updated our extensions locally to work for 3.2.
    We've also managed to install 3.2 on an older version of our database (the difference at the moment is not clear, though more information may be provided later when we finish looking into it)

    Anyway, we've copied over the mysql database from our prod 3.0.3 instance, and we tried running the wizard.
    On the unattended wizard, at the 40% step it just crashes with no output.
    On the GUI wizard, at the 40% step we are given this error message:

    PHP error occured : msg=Uncaught DivisionByZeroError: Division by zero in /opt/app-root/src/web/setup/applicationinstaller.class.inc.php:722
    Stack trace:
    #0 /opt/app-root/src/web/setup/applicationinstaller.class.inc.php(309): ApplicationInstaller::DoUpdateDBSchema(Array, 'env-production', Array, 'production', false, 'https://dev.ods...')
    #1 /opt/app-root/src/web/setup/wizardsteps.class.inc.php(2443): ApplicationInstaller->ExecuteStep('db-schema')
    #2 /opt/app-root/src/web/setup/ajax.dataloader.php(176): WizStepSummary->AsyncAction(Object(Combodo\iTop\Application\WebPage\AjaxPage), 'execute_step', Array)
    #3 {main}
      thrown, no=1, file=/opt/app-root/src/web/setup/applicationinstaller.class.inc.php, line=722
    

    We also have an error.log, the last few errors are as follows (replaced some sensitive info with stars):

    2024-11-27 18:54:06 | Error   |       | #0 /opt/app-root/src/web/core/cmdbsource.class.inc.php(580): CMDBSource::DBQuery('SELECT\n DISTINC...')
    #1 /opt/app-root/src/web/core/dbobjectset.class.php(771): CMDBSource::Query('SELECT\n DISTINC...')
    #2 /opt/app-root/src/web/core/dbobjectset.class.php(1009): DBObjectSet->Load()
    #3 /opt/app-root/src/web/core/userrights.class.inc.php(1962): DBObjectSet->Fetch()
    #4 /opt/app-root/src/web/core/userrights.class.inc.php(942): UserRights::FindUser(************, 'internal')
    #5 /opt/app-root/src/web/application/loginform.class.inc.php(73): UserRights::CheckCredentials((************,, 'form', 'internal')
    #6 /opt/app-root/src/web/application/applicationextension.inc.php(115): LoginForm->OnCheckCredentials(0)
    #7 /opt/app-root/src/web/application/loginwebpage.class.inc.php(498): AbstractLoginFSMExtension->LoginAction('check credentia...', 0)
    #8 /opt/app-root/src/web/application/loginwebpage.class.inc.php(1028): LoginWebPage::Login(0)
    #9 /opt/app-root/src/web/application/loginwebpage.class.inc.php(1008): LoginWebPage::DoLoginEx('backoffice', false, 0)
    #10 /opt/app-root/src/web/pages/UI.php(318): LoginWebPage::DoLogin()
    #11 {main} | IssueLog |||
    2024-11-27 19:44:17 | Error   |       | Uncaught Error: Failed opening required '/opt/app-root/src/web/env-production/dictionaries/languages.php' (include_path='/opt/app-root/src/web/lib/pear/archive_tar:/opt/app-root/src/web/lib/pear/console_getopt:/opt/app-root/src/web/lib/pear/pear-core-minimal/src:/opt/app-root/src/web/lib/pear/pear_exception:.:/opt/app-root/src:/usr/share/pear') in /opt/app-root/src/web/core/metamodel.class.php:6473
    Stack trace:
    #0 /opt/app-root/src/web/core/metamodel.class.php(6383): MetaModel::LoadConfig(Object(Config), true)
    #1 /opt/app-root/src/web/application/startup.inc.php(103): MetaModel::Startup('/opt/app-root/s...', false, true, false, 'production')
    #2 /opt/app-root/src/web/pages/UI.php(308): require_once('/opt/app-root/s...')
    #3 {main}
    
    Next Error: Class "Combodo\iTop\Attachments\Hook\EventListener" not found in /opt/app-root/src/web/sources/Service/Events/EventService.php:50
    Stack trace:
    #0 /opt/app-root/src/web/core/metamodel.class.php(6401): Combodo\iTop\Service\Events\EventService::InitService()
    #1 /opt/app-root/src/web/application/startup.inc.php(103): MetaModel::Startup('/opt/app-root/s...', false, true, false, 'production')
    #2 /opt/app-root/src/web/pages/UI.php(308): require_once('/opt/app-root/s...')
    #3 {main}
      thrown | IssueLog |||
    array (
      'type' => 1,
      'file' => '/opt/app-root/src/web/sources/Service/Events/EventService.php',
      'line' => 50,
    )
    

    If you have any ideas of how we should go about allowing iTop 3.2 to use this db, it would be appreciated. We will continue testing with older versions of the db and hopefully find something.

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2024-11-28

    Seeing you reported another issue recently as well: did you just grab the iTop 3.2.0 community package; and unzip everything correctly?

     
    • Jacques Dancause

      Yes - the issue we recently reported was also related to the update but we sorted that one out. Yes, we followed the instructions & unzipped everything correctly.

      Here is the entire setup.log, hopefully that gives some more info?

       | SetupLog |||
      2024-11-28 16:28:22 | Info    |       | ##### STEP  duration: 0s | SetupLog |||
      2024-11-28 16:28:22 | Info    |       | operation 'async_action', peak memory usage. 915376 | SetupLog |||
      2024-11-28 16:28:22 | Info    |       | ##### STEP copy start | SetupLog |||
      2024-11-28 16:28:22 | Info    |       | ##### STEP copy duration: 0s | SetupLog |||
      2024-11-28 16:28:22 | Info    |       | operation 'async_action', peak memory usage. 915408 | SetupLog |||
      2024-11-28 16:28:22 | Info    |       | ##### STEP compile start | SetupLog |||
      2024-11-28 16:28:22 | Info    |       | Compiling data model. | SetupLog |||
      2024-11-28 16:28:22 | Info    |       | ----> Entering maintenance mode | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | For theme 'darkmoon' precompiled file used: '/opt/app-root/src/web/data/precompiled_styles/darkmoon.css' | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | No theme 'darkmoon' compilation was required during setup. | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | For theme 'fullmoon-high-contrast' precompiled file used: '/opt/app-root/src/web/data/precompiled_styles/fullmoon-high-contrast.css' | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | No theme 'fullmoon-high-contrast' compilation was required during setup. | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | For theme 'fullmoon-protanopia-deuteranopia' precompiled file used: '/opt/app-root/src/web/data/precompiled_styles/fullmoon-protanopia-deuteranopia.css' | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | No theme 'fullmoon-protanopia-deuteranopia' compilation was required during setup. | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | For theme 'fullmoon-tritanopia' precompiled file used: '/opt/app-root/src/web/data/precompiled_styles/fullmoon-tritanopia.css' | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | No theme 'fullmoon-tritanopia' compilation was required during setup. | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | For theme 'fullmoon' precompiled file used: '/opt/app-root/src/web/data/precompiled_styles/fullmoon.css' | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | No theme 'fullmoon' compilation was required during setup. | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | For theme 'test-red' precompiled file used: '/opt/app-root/src/web/data/precompiled_styles/test-red.css' | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | No theme 'test-red' compilation was required during setup. | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | For theme 'light-grey' precompiled file used: '/opt/app-root/src/web/data/precompiled_styles/light-grey.css' | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | No theme 'light-grey' compilation was required during setup. | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | Data model successfully compiled to '/opt/app-root/src/web/env-production'. | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | <---- Exiting maintenance mode | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | ##### STEP compile duration: 6.39s | SetupLog |||
      2024-11-28 16:28:28 | Info    |       | operation 'async_action', peak memory usage. 8103768 | SetupLog |||
      2024-11-28 16:28:29 | Info    |       | ##### STEP db-schema start | SetupLog |||
      2024-11-28 16:28:29 | Info    |       | Update Database Schema for environment 'production'. | SetupLog |||
      2024-11-28 16:28:29 | Info    |       | MetaModel::Startup (ModelOnly = 1) | SetupLog |||
      2024-11-28 16:28:29 | Info    |       | Renaming 'priv_internalUser' into 'priv_internaluser' (lowercase) | SetupLog |||
      2024-11-28 16:28:29 | Info    |       | Renaming 'priv_internalUser' failed (already done in a previous upgrade?) | SetupLog |||
      2024-11-28 16:28:29 | Info    |       | Cleanup of 'priv_change' to remove orphan records | SetupLog |||
      2024-11-28 16:28:29 | Info    |       | There is a total of 0 records in priv_change. | SetupLog |||
      2024-11-28 16:28:29 | Info    |       | ##### STEP db-schema duration: 0.79s | SetupLog |||
      2024-11-28 16:28:29 | Error   |       | Setup error: PHP error occured : msg=Uncaught DivisionByZeroError: Division by zero in /opt/app-root/src/web/setup/applicationinstaller.class.inc.php:722
      Stack trace:
      #0 /opt/app-root/src/web/setup/applicationinstaller.class.inc.php(309): ApplicationInstaller::DoUpdateDBSchema(Array, 'env-production', Array, 'production', false, 'https://dev.ods...')
      #1 /opt/app-root/src/web/setup/wizardsteps.class.inc.php(2443): ApplicationInstaller->ExecuteStep('db-schema')
      #2 /opt/app-root/src/web/setup/ajax.dataloader.php(176): WizStepSummary->AsyncAction(Object(Combodo\iTop\Application\WebPage\AjaxPage), 'execute_step', Array)
      #3 {main}
        thrown, no=1, file=/opt/app-root/src/web/setup/applicationinstaller.class.inc.php, line=722 | SetupLog |||
      2024-11-28 16:30:02 | Ok      |       | Info - CheckGraphviz | SetupLog |||
      2024-11-28 16:30:02 | Ok      |       | Info - PHP functions disabled:  | SetupLog |||
      2024-11-28 16:30:02 | Ok      |       | Info - /usr/bin/dot -V said: dot - graphviz version 2.40.1 (0) | SetupLog |||
      2024-11-28 16:30:02 | Info    |       | operation 'async_action', peak memory usage. 911064 | SetupLog |||
      2024-11-28 16:30:04 | Info    |       | GetApplicationVersion returns: product_name: iTop, product_version: 3.0.3-10998 | SetupLog |||
      2024-11-28 16:30:05 | Ok      |       | Info - CheckBackupPrerequisites | SetupLog |||
      2024-11-28 16:30:05 | Ok      |       | Info - PHP functions disabled:  | SetupLog |||
      2024-11-28 16:30:05 | Ok      |       | Info - mysqldump -V said: mysqldump  Ver 10.19 Distrib 10.3.39-MariaDB, for Linux (x86_64) | SetupLog |||
      2024-11-28 16:30:05 | Info    |       | operation 'async_action', peak memory usage. 890272 | SetupLog |||
      

      It seems that division by zero happens when "priv_change" is detected to have 0 records ("There is a total of 0 records in priv_change."), and the error happens at this line in the itop source code:

      "SetupLog::Info("There are $iOrphanCount useless records in {$sDBPrefix}priv_change (".sprintf('%.2f', ((100.0*$iOrphanCount)/$iTotalCount))."%)");"
      
       

      Last edit: Jacques Dancause 2024-11-28
  • Jacques Dancause

    Hey - unfortunately we are not able to get the other version of the DB that worked back. We have tried a fresh install with an empty database, and it worked successfully, but with the production database it always gives us this division by zero error. Is it because we are copying the database without the activity log?

     
    • Jeffrey Bostoen

      Jeffrey Bostoen - 2024-12-02

      Without what activity log exactly?

       
      • Jacques Dancause

        We have two versions of backups from our prod db - one without and one with priv_change table.

        We tried running the setup WITH the contents of priv_change, and it crashed on 60% this time:

        Module itop-structure : error when calling module installer class StructureInstaller for AfterDatabaseCreation handler: ModulelId = itop-structure, ModuleInstallerClass = StructureInstaller, ModuleInstallerHandler = AfterDatabaseCreation, ExceptionClass = MySQLException, ExceptionMessage = Failed to issue SQL query: 
        
        query = INSERT INTO `priv_action_newsroom` (`id`,`title`,`message`,`icon_data`,`icon_mimetype`,`icon_filename`,`icon_downloads_count`,`priority`,`test_recipient_id`,`recipients`,`url`) VALUES ('3', '$this->friendlyname$', 'You have been mentioned by $current_contact->friendlyname$', '', '', '', 0, '3', 0, 'SELECT Person WHERE id = :mentioned->id', '$this->url()$'), mysql_errno = 1062, mysql_error = Duplicate entry '3' for key 'PRIMARY' 
        

        Edit:

        We ran a query to drop the contents of priv_action_newsroom, and the setup worked successfully. I'm not sure why there was duplicate entry, but things seem to be working properly.

         

        Last edit: Jacques Dancause 2024-12-02

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.