Hi Tomas

I was able to solve the problem which apparently appeared because of a corrupt database dump. See my e-mail to mailinglist "koha-devel" from 22 Jul 17:38 (see below).

Best wishes and many thanks: Michael
--
Geschäftsführer · Diplombibliothekar BBS, Informatiker eidg. Fachausweis
Admin Kuhn GmbH · Pappelstrasse 20 · 4123 Allschwil · Schweiz
T 0041 (0)61 261 55 61 · E m...@adminkuhn.ch · W www.adminkuhn.ch



Am 24.07.24 um 14:25 schrieb Tomas Cohen Arazi:

Hi, Michael.

What DB engine and version are you using?

Is it possible for you to share a dump for that DB to some of us for review?

El mié, 10 jul 2024 a la(s) 7:46 a.m., Michael Kuhn via Koha-devel (koha-devel@lists.koha-community.org <mailto:koha-devel@lists.koha-community.org>) escribió:

    Hi

    We have loaded our Koha 19.11 database into a new Koha 24.05 instance.
    When running "koha-upgrade-schema" the following error appears:

    ...
    Upgrade to 19.12.00.017  [12:00:41]: Bug 21674 - Add unique key
    (parent_id, branchcode) to library_group
    {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: Duplicate entry '0'
    for key 'PRIMARY'  at /usr/share/perl5/DBIx/Class/Schema.pm line 1118.
DBIx::Class::Schema::throw_exception(Koha::Schema=HASH(0x55a4b4a0dba8),
    "DBI Exception: DBD::mysql::db do failed: Duplicate entry '0' "...)
    called at /usr/share/perl5/DBIx/Class/Storage.pm line 113
DBIx::Class::Storage::throw_exception(DBIx::Class::Storage::DBI::mysql=HASH(0x55a4b9ff1b70), "DBI Exception: DBD::mysql::db do failed: Duplicate entry '0' "...) called at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1623
             DBIx::Class::Storage::DBI::__ANON__("DBD::mysql::db do failed:
    Duplicate entry '0' for key 'PRIMARY'", DBI::db=HASH(0x55a4ba7d2b38),
    undef) called at
    /usr/share/koha/intranet/cgi-bin/installer/data/mysql/updatedatabase.pl 
<http://updatedatabase.pl>
    line 20736


    Does anyone know how to solve this problem? At the moment I'm not even
    able to find out in which table the duplicate entry can be found...

    Best wishes: Michael
-- Geschäftsführer · Diplombibliothekar BBS, Informatiker eidg. Fachausweis
    Admin Kuhn GmbH · Pappelstrasse 20 · 4123 Allschwil · Schweiz
    T 0041 (0)61 261 55 61 · E m...@adminkuhn.ch
    <mailto:m...@adminkuhn.ch> · W www.adminkuhn.ch <http://www.adminkuhn.ch>
    _______________________________________________
    Koha-devel mailing list
    Koha-devel@lists.koha-community.org
    <mailto:Koha-devel@lists.koha-community.org>
    https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
    <https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel>
    website : https://www.koha-community.org/
    <https://www.koha-community.org/>
    git : https://git.koha-community.org/ <https://git.koha-community.org/>
    bugs : https://bugs.koha-community.org/
    <https://bugs.koha-community.org/>






-------- Weitergeleitete Nachricht --------
Betreff: Re: [Koha-devel] [Koha] {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: Duplicate entry '0' for key 'PRIMARY'
Datum: Mon, 22 Jul 2024 17:38:04 +0200
Von: Michael Kuhn via Koha-devel <koha-devel@lists.koha-community.org>
Antwort an: Michael Kuhn <m...@adminkuhn.ch>
Organisation: Admin Kuhn GmbH
An: Philippe Blouin <philippe.blo...@inlibro.com>, koha-devel@lists.koha-community.org

Hi Philippe

You wrote:

 > If you went with an existing 23.11 and tried to overwrite the database
 > with you 19.05 one, it's possible it got conflicts since it drop-and-
 > add in the order in the file and dependencies might break.  Always
 > easier to just drop the old database and load the "new" one in an
 > empty space.

Thanks for this hint!

 > Then you went from 19 to 23.06.00.013, which is much further, but then
 > failed on something unrelated to any previous error.  (beside being a
 > constraint, like the primary key earlier).  Cannot dropping something
 > that doesn't exist is NOT a deal breaker, so try
 >
 > comment installer/data/mysql/db_revs/230600014.pl line 11, and try
 > again.

After all we found out the database dump I was provided with was corrupt or unusual in at least two ways: 1) it didn't contain the final line "Dump completed" and so really was incomplete, but 2) it did include lines like the following (and the corresponding SQL commands) that are usually not included in the database dump:

-- Constraints der exportierten Tabellen
-- Constraints der Tabelle `accountlines`
-- Constraints der Tabelle `account_credit_types_branches`
etc. etc.

Provided with an incorrupt dump I was able to load it into the MariaDB server and the update from Koha 19.11 to 24.05 worked like a charm. No errors at all.

Best wishes and many thanks for your help: Michael
--
Geschäftsführer · Diplombibliothekar BBS, Informatiker eidg. Fachausweis
Admin Kuhn GmbH · Pappelstrasse 20 · 4123 Allschwil · Schweiz
T 0041 (0)61 261 55 61 · E m...@adminkuhn.ch · W www.adminkuhn.ch



> On 2024-07-10 12:30, Michael Kuhn wrote:
>> Hi Philippe
>>
>> You wrote:
>>
>> > If you're a bit adventurous (and have some time, which you're probably
>> > thinking you've burnt enough already): try to update to 20.05, for
>> > example, using 20.05 code.
>> >
>> > So you reset your installation (you have saved your DB, right?), then
>> > instead of installing a 24.05, you install an older version, like
>> > 20.05 and do the update.
>> >
>> > The specific lines in updatedatabase.pl probably are the same, but a
>> > lot of underlying plumbing could be different and work badly with your
>> > system.  I'd start by ruling that out.
>>
>> 1. On an different host with Koha 23.11 I loaded the database which
>> then showed the following error:
>>
>> ERROR 1452 (23000) at line 8292833: Cannot add or update a child row:
>> a foreign key constraint fails (`koha_test`.`#sql-alter-368-2a`,
>> CONSTRAINT `borrower_message_transport_preferences_ibfk_1` FOREIGN KEY
>> (`borrower_message_preference_id`) REFERENCES
>> `borrower_message_preferences` (`borrower_)
>>
>> 2. I didn't care for it and then tried to update the database. This
>> time the update process went far far further but it still aborted here:
>>
>> Upgrade to 23.06.00.013  [17:56:51]: Bug 28966 - Holds queue view too
>> slow to load for large numbers of holds
>> ERROR - {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: Can't DROP
>> CONSTRAINT `tmp_holdsqueue_ibfk_1`; check that it exists at
>> /usr/share/koha/lib/C4/Installer.pm line 741
>>
>> This seems to be a different problem and I'm hoping the solution could
>> lead to the road of success... Do you happen to know how to solve this?
>>
>> 3. Furthermore I saw the database dump file I received for the update
>> ends like this:
>>
>> --
>> -- Constraints der Tabelle `virtualshelves`
>> --
>> ALTER TABLE `virtualshelves`
>>   ADD CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`)
>> REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE
>> SET NULL;
>> COMMIT;
>>
>> /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
>> /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
>> /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
>>
>> while the database dump files I usually create myself do not contain
>> constraints at all and end like this:
>>
>> -- Dump completed on 2024-07-10  6:25:22
>>
>> Does this make sense to you?
>>
>> Best wishes: Michael


_______________________________________________
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/


_______________________________________________
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/

Reply via email to