Bugzilla – Bug 17283
Constraint violation in scanner after reverting file name change
Last modified: 2011-12-13 22:26:01 UTC
The following sequence results in a constraint violation in the scanner code and the only way to be able to perform a rescan again afterwards is to restart the server. 1. Rename a music file (test1.mp3 -> test2.mp3) 2. Perform a new/changed rescan and let it finish 3. Rename the music file again back to the original name (test2.mp3 -> test1.mp3) 4. Perform a new/changed rescan The problem only happens if you change back the file to the original name, so it probably doesn't affect a lot of users, but I thought I'd register it since it's pretty serious if this happens. The sequence was tested in svn "onebrowser branch" 32501 In point 2, the log correctly reports: ====================== [11-06-06 08:46:19.2885] Slim::Utils::Scanner::Local::rescan (163) Discovering files in /mnt/mp3music_small [11-06-06 08:46:19.4885] Slim::Utils::Scanner::Local::__ANON__ (235) Removing deleted files (1) [11-06-06 08:46:19.4928] Slim::Utils::Scanner::Local::__ANON__ (291) Scanning new files (1) [11-06-06 08:46:19.4955] Slim::Utils::Scanner::Local::__ANON__ (347) Rescanning changed files (0) [11-06-06 08:46:19.4967] Slim::Utils::Scanner::Local::deleted (477) Handling deleted track file:///mnt/mp3music_small/mp3/testar/test1.mp3 [11-06-06 08:46:19.5712] Slim::Music::Artwork::precacheAllArtwork (435) Starting precacheArtwork for 1 albums [11-06-06 08:46:19.6350] Slim::Music::Artwork::__ANON__ (528) precacheArtwork finished in 0.0631330013275146 The problem happens in point 4, where the log reports the following and the scanner is locked in "in progress" mode so the only way to get back is to restart the server. The "Rescan" button is disabled until you have restarted the server. ======================= [11-06-06 08:46:47.0781] Slim::Utils::Scanner::Local::rescan (163) Discovering files in /mnt/mp3music_small [11-06-06 08:46:47.2771] Slim::Utils::Scanner::Local::__ANON__ (235) Removing deleted files (1) [11-06-06 08:46:47.2806] Slim::Utils::Scanner::Local::__ANON__ (291) Scanning new files (1) [11-06-06 08:46:47.2836] Slim::Utils::Scanner::Local::__ANON__ (347) Rescanning changed files (0) [11-06-06 08:46:47.2845] Slim::Utils::Scanner::Local::deleted (477) Handling deleted track file:///mnt/mp3music_small/mp3/testar/test2.mp3 [11-06-06 08:46:47.3012] Slim::Schema::Storage::throw_exception (119) Error: DBI Exception: DBD::SQLite::st execute failed: constraint failed foreign key constraint failed [for Statement "INSERT INTO tracks (tagversion,bitrate,audio_offset,drm,audio_size,block_alignment,vbr_scale,remote,audio,titlesort,cover,timestamp,url,lossless,urlmd5,channels,primary_artist,samplerate,secs,filesize,album,content_type,tracknum,titlesearch,title,disc,musicbrainz_id,year) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"] [11-06-06 08:46:47.3020] Slim::Schema::Storage::throw_exception (119) Backtrace: frame 0: Slim::Utils::Log::logBacktrace (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Schema/Storage.pm line 119) frame 1: Slim::Schema::Storage::throw_exception (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/CPAN/DBIx/Class/Storage/DBI.pm line 1006) frame 2: DBIx::Class::Storage::DBI::__ANON__ (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Schema.pm line 2949) frame 3: Slim::Schema::_insertHash (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Schema.pm line 1342) frame 4: Slim::Schema::_createTrack (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Schema.pm line 1601) frame 5: Slim::Schema::_newTrack (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Schema.pm line 1799) frame 6: Slim::Schema::updateOrCreateBase (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Utils/Scanner/Local.pm line 688) frame 7: Slim::Utils::Scanner::Local::__ANON__ (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/CPAN/DBIx/Class/Storage/DBI.pm line 638) frame 8: (eval) (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/CPAN/DBIx/Class/Storage/DBI.pm line 627) frame 9: DBIx::Class::Storage::DBI::txn_do (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/lib/DBIx/Class/Schema.pm line 650) frame 10: DBIx::Class::Schema::txn_do (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Utils/Scanner/Local.pm line 748) frame 11: Slim::Utils::Scanner::Local::new (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Utils/Scanner/Local.pm line 321) frame 12: Slim::Utils::Scanner::Local::__ANON__ (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Utils/Scheduler.pm line 150) frame 13: (eval) (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Utils/Scheduler.pm line 150) frame 14: Slim::Utils::Scheduler::run_tasks (/opt/squeezecenter76_smd_onebrowser/slimserver.pl line 676) frame 15: main::idle (/opt/squeezecenter76_smd_onebrowser/slimserver.pl line 643) frame 16: main::main (/opt/squeezecenter76_smd_onebrowser/slimserver.pl line 1138) [11-06-06 08:46:47.3034] Slim::Schema::Storage::throw_exception (119) Error: Carp::Clan::__ANON__(): DBI Exception: DBD::SQLite::st execute failed: constraint failed foreign key constraint failed [for Statement "INSERT INTO tracks (tagversion,bitrate,audio_offset,drm,audio_size,block_alignment,vbr_scale,remote,audio,titlesort,cover,timestamp,url,lossless,urlmd5,channels,primary_artist,samplerate,secs,filesize,album,content_type,tracknum,titlesearch,title,disc,musicbrainz_id,year) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"] at /media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Schema/Storage.pm line 123 [11-06-06 08:46:47.3039] Slim::Schema::Storage::throw_exception (119) Backtrace: frame 0: Slim::Utils::Log::logBacktrace (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Schema/Storage.pm line 119) frame 1: Slim::Schema::Storage::throw_exception (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/CPAN/DBIx/Class/Storage/DBI.pm line 660) frame 2: DBIx::Class::Storage::DBI::txn_do (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/lib/DBIx/Class/Schema.pm line 650) frame 3: DBIx::Class::Schema::txn_do (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Utils/Scanner/Local.pm line 748) frame 4: Slim::Utils::Scanner::Local::new (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Utils/Scanner/Local.pm line 321) frame 5: Slim::Utils::Scanner::Local::__ANON__ (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Utils/Scheduler.pm line 150) frame 6: (eval) (/media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Utils/Scheduler.pm line 150) frame 7: Slim::Utils::Scheduler::run_tasks (/opt/squeezecenter76_smd_onebrowser/slimserver.pl line 676) frame 8: main::idle (/opt/squeezecenter76_smd_onebrowser/slimserver.pl line 643) frame 9: main::main (/opt/squeezecenter76_smd_onebrowser/slimserver.pl line 1138) [11-06-06 08:46:47.3059] Slim::Utils::Scheduler::run_tasks (157) Error: Scheduler task failed: Carp::Clan::__ANON__(): Carp::Clan::__ANON__(): DBI Exception: DBD::SQLite::st execute failed: constraint failed foreign key constraint failed [for Statement "INSERT INTO tracks (tagversion,bitrate,audio_offset,drm,audio_size,block_alignment,vbr_scale,remote,audio,titlesort,cover,timestamp,url,lossless,urlmd5,channels,primary_artist,samplerate,secs,filesize,album,content_type,tracknum,titlesearch,title,disc,musicbrainz_id,year) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"] at /media/disk2/squeezecenter/7.6/server_smd_onebrowser/Slim/Schema/Storage.pm line 123
I wasn't able to replicate this bug following the steps outlined above. I tried it several times with different files. All scans completed successfully. Perhaps the more serious problem here is the inability of the server to gracefully recover from a scanner crash.
Just saw this too: replaced a bad rip with new files of the same name. While they would be played (referenced by name in the DB?), BMF would fail with the constraint messages Erland posted.
== Auto-comment from SVN commit #33687 to the slim repo by agrundman == == http://svn.slimdevices.com/slim?view=revision&revision=33687 == Fixed bug 17283. lastAlbum cache was left over even if the album was removed because it no longer had any tracks. Now clear the lastAlbum cache if we remove the album in the cache
Verification passed on 7.7.1 r33735,hence closing this bug.