Upgrade from 4.0.24 to 5.0.20

Moderator: crythias

Post Reply
carroarmato0
Znuny newbie
Posts: 2
Joined: 18 Oct 2017, 15:01
Znuny Version: 3.3.15

Upgrade from 4.0.24 to 5.0.20

Post by carroarmato0 »

Hello,

I'm busy upgrading an old installation from OTRS 3.3.15 all the way to 5.0.20. And I'm almost there.
I did all the upgrades in order in between.

Now I'm doing the upgrade from 4.0.24 to 5.0.20, but I'm stuck in the middle of applying the DB Updates:

Code: Select all

otrs@otrsdev1:~$ scripts/DBUpdate-to-5.pl
....
Step 7 of 18: Migrate notifications to event based notifications...ERROR: OTRS-DBUpdate-to-5.pl-99 Perl: 5.20.2 OS: linux Time: Wed Oct 11 15:06:07 2017

 Message: Could not get ID for just added notification 'Old Ticket new note notification'!

 Traceback (512): 
   Module: Kernel::System::NotificationEvent::NotificationAdd Line: 380
   Module: main::_MigrateNotifications Line: 1113
   Module: scripts/DBUpdate-to-5.pl Line: 166

error.

[Wed Oct 11 15:06:07 2017] DBUpdate-to-5.pl: Died at scripts/DBUpdate-to-5.pl line 171.
This is weird as the record is present in the database, but somehow it didn't get the ID back...
All tables are using INNODB.
carroarmato0
Znuny newbie
Posts: 2
Joined: 18 Oct 2017, 15:01
Znuny Version: 3.3.15

Re: Upgrade from 4.0.24 to 5.0.20

Post by carroarmato0 »

I did some more digging in.

At the customer where I'm doing the upgrade they use ProxySQL.

To my understanding, it's a Master - Slave setup where the writes go to the master and the reads are split among the slaves.

I don't think OTRS is written for that kind of scenario.

Code: Select all

    # get database object
    my $DBObject = $Kernel::OM->Get('Kernel::System::DB');

    # insert data into db
    return if !$DBObject->Do(
        SQL => '
            INSERT INTO notification_event
                (name, valid_id, comments, create_time, create_by, change_time, change_by)
            VALUES (?, ?, ?, current_timestamp, ?, current_timestamp, ?)',
        Bind => [
            \$Param{Name}, \$Param{ValidID}, \$Param{Comment},
            \$Param{UserID}, \$Param{UserID},
        ],
    );
 
    # get id
    $DBObject->Prepare(
        SQL  => 'SELECT id FROM notification_event WHERE name = ?',
        Bind => [ \$Param{Name} ],
    );

    my $ID;

    while ( my @Row = $DBObject->FetchrowArray() ) {
        $ID = $Row[0];
    }
    
    # error handling
    if ( !$ID ) {
        $Kernel::OM->Get('Kernel::System::Log')->Log(
            Priority => 'error',
            Message  => "Could not get ID for just added notification '$Param{Name}'!",
        );
        return;
    }
It performs the insert... then tries fetching the result afterwards which might not have already arrived on the slave, resulting in an empty ID.

Ofcourse if you go checkout the database, you'll see that the inserts are present.
Post Reply