ConstraintViolation after migrating and reloading existing VLC database
$> \cp /tmp/ml.db /tmp/test.db && gdb --args ./test/discoverer/discoverer -m /tmp/test.db
...
terminate called after throwing an instance of 'medialibrary::sqlite::errors::ConstraintPrimaryKey'
what(): Request [INSERT INTO MediaArtistRelation VALUES(?, ?)] aborted due to constraint violation (UNIQUE constraint failed: MediaArtistRelation.media_id, MediaArtistRelation.artist_id)
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1 0x00007ffff73a2536 in __GI_abort () at abort.c:79
#2 0x00007ffff75fc87a in () at /lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff7607ffa in () at /lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff7608065 in () at /lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff760834d in __cxa_rethrow () at /lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007ffff7bdbd72 in medialibrary::sqlite::Tools::executeInsert<long, long&>(medialibrary::sqlite::Connection*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long&&, long&)
(dbConnection=0x555555608610, req="INSERT INTO MediaArtistRelation VALUES(?, ?)") at ../src/database/SqliteTools.h:380
#7 0x00007ffff7bd64d8 in medialibrary::Artist::addMedia(medialibrary::Media const&) (this=0x7fffc4108890, media=...)
at ../src/Artist.cpp:165
#8 0x00007ffff7d60b1b in medialibrary::parser::MetadataAnalyzer::link(medialibrary::parser::IItem&, medialibrary::Album&, std::shared_ptr<medialibrary::Artist>, std::shared_ptr<medialibrary::Artist>, bool, std::shared_ptr<medialibrary::Thumbnail>)
(this=0x555555606010, item=...,
album=..., albumArtist=std::shared_ptr<class medialibrary::Artist> (use count 1, weak count 0) = {...}, artist=std::shared_ptr<class medialibrary::Artist> (use count 1, weak count 0) = {...}, newAlbum=false, mediaThumbnail=std::shared_ptr<class medialibrary::Thumbnail> (empty) = {...}) at ../src/metadata_services/MetadataParser.cpp:1365
#9 0x00007ffff7d5e424 in medialibrary::parser::MetadataAnalyzer::parseAudioFile(medialibrary::parser::IItem&, medialibrary::parser::MetadataAnalyzer::Cache&) (this=0x555555606010, item=..., cache=...) at ../src/metadata_services/MetadataParser.cpp:986
#10 0x00007ffff7d58a58 in medialibrary::parser::MetadataAnalyzer::run(medialibrary::parser::IItem&) (this=0x555555606010, item=...)
at ../src/metadata_services/MetadataParser.cpp:221
#11 0x00007ffff7d960fc in medialibrary::parser::Worker::mainloop() (this=0x555555607020) at ../src/parser/ParserWorker.cpp:238
#12 0x00007ffff7da04f7 in std::__invoke_impl<void, void (medialibrary::parser::Worker::*)(), medialibrary::parser::Worker*>(std::__invoke_memfun_deref, void (medialibrary::parser::Worker::*&&)(), medialibrary::parser::Worker*&&)
(__f=@0x7fffdc041e00: (void (medialibrary::parser::Worker::*)(class medialibrary::parser::Worker * const)) 0x7ffff7d9572e <medialibrary::parser::Worker::mainloop()>, __t=@0x7fffdc041df8: 0x555555607020) at /usr/include/c++/11/bits/invoke.h:74
#13 0x00007ffff7da0455 in std::__invoke<void (medialibrary::parser::Worker::*)(), medialibrary::parser::Worker*>(void (medialibrary::parser::Worker::*&&)(), medialibrary::parser::Worker*&&)
(__fn=@0x7fffdc041e00: (void (medialibrary::parser::Worker::*)(class medialibrary::parser::Worker * const)) 0x7ffff7d9572e <medialibrary::parser::Worker::mainloop()>) at /usr/include/c++/11/bits/invoke.h:96
#14 0x00007ffff7da03c5 in std::thread::_Invoker<std::tuple<void (medialibrary::parser::Worker::*)(), medialibrary::parser::Worker*> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) (this=0x7fffdc041df8) at /usr/include/c++/11/bits/std_thread.h:253
#15 0x00007ffff7da037e in std::thread::_Invoker<std::tuple<void (medialibrary::parser::Worker::*)(), medialibrary::parser::Worker*> >::operator()() (this=0x7fffdc041df8) at /usr/include/c++/11/bits/std_thread.h:260
#16 0x00007ffff7da0362 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (medialibrary::parser::Worker::*)(), medialibrary::parser::Worker*> > >::_M_run() (this=0x7fffdc041df0) at /usr/include/c++/11/bits/std_thread.h:211
#17 0x00007ffff76328f4 in () at /lib/x86_64-linux-gnu/libstdc++.so.6
#18 0x00007ffff71ecd80 in start_thread (arg=0x7fffd3fff640) at pthread_create.c:481
#19 0x00007ffff7478b6f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Edited by Hugo Beauzée-Luyssen