Bug 4402 - If music library unavailable duplicate album entries created
: If music library unavailable duplicate album entries created
Status: CLOSED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Database
: 7.0
: PC Windows XP
: P2 minor (vote)
: 7.x
Assigned To: Andy Grundman
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-10-20 11:47 UTC by jeff
Modified: 2009-07-31 10:14 UTC (History)
3 users (show)

See Also:
Category: ---


Attachments
set of mp3s in directories with tags (20.83 KB, application/octet-stream)
2006-11-09 15:51 UTC, Chris Owens
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jeff 2006-10-20 11:47:48 UTC
I use a USB 2.0 external drive for music storage. I generally power off the drive when not listening to music via my Squeezebox. If I forget to power up the drive and then select music to play, of course nothing happens, however a side effect is that the music selected is now listed twice in my library, e.g., once in the appropriate manner and another instance of Artist, Album with no songs. I then have to rescan to get rid of the empty album. Can there be a more graceful way of handling the error such as a message to the effect of "Library unavailable" without causing an empty album to be added to the database?
Comment 1 Chris Owens 2006-10-30 11:27:09 UTC
I wasn't able to reproduce this phenomenon of having music added to the library, but it certainly seems like error reporting in the case of not being able to find music could be improved.

Do you remember the steps you went through to get the music to appear twice?
Comment 2 jeff 2006-10-31 06:08:02 UTC
I can reproduced this every time as follows:

1. USB drive containing music library is off. 

2. Use the player UI to browse to Artist and then album.

3. Press play on remote. 

4. Player display shows "Empty" when pressing right at the album name. 

5. Viewing the album in both the player and web UI shows no songs in the album. 

6. Power on the USB drive.

7. In the web UI Browse Music Folder to Artist and then album. (Adds songs to database.)

8. Browse to the album via the web or player UI and there are now two albums listed (duplicates), one with the songs and the other with no songs. 



Comment 3 jeff 2006-11-01 11:21:02 UTC
In order to clarify, I guess the original bug summary could have been entitled "Attempting to play an album without the music library being online creates an empty album in the database". The duplicate is created when browsing to the album by folders. In any event, one either has an empty album or a duplicate album with no music contained therein. 
Comment 4 Chris Owens 2006-11-06 14:55:22 UTC
I still don't see it, I'm afraid.

What is the directory structure of your music on the USB drive?  Are your tags good or is Slimserver guessing some or all tag data from the directory information?  What kind of files are your music?  MP3?  Flac?  Other?  A mix?
Comment 5 jeff 2006-11-07 04:54:42 UTC
This is not reproduceable at your end? That's strange I can reproduce this at will. 

Directory structure is:	USB Drive\My Music\Artist\AlbumName\Tracknum Trackname

The tags appear to be good and I have experienced no problems or issues locating files when browsing by artist, album, year, genre, etc. 

	Server settings---Formatting---Guess Tags Formats = 0 (i.e., do not guess)

	Files are about 95% Flac with the remainder MP3 and just a few wma and are all on the USB drive. 

In order to assist I just attempted to play an album while the USB drive was off and captured the log file. After attempting to play, the album now contains zero songs in both the web and player UI even if the USB drive is reconnected, i.e., requires a rescan to pick up songs.)


*****************
Your data source needs to be configured. Please open your web browser,
go to the following URL, and click on the "Server Settings" link.

The URL to access SlimServer is now:

	http://Aquinas:9000/

ERROR: playmode: Couldn't gotoNext song on playlist, stopping

ERROR: Error executing 'INSERT INTO playlist_track (playlist, position, track) VALUES (?, ?, ?)': DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`slimserver/playlist_track`, CONSTRAINT `playlist_track_ibfk_1` FOREIGN KEY (`track`) REFERENCES `tracks` (`id`) ON DELETE CASCADE) at C:\Program Files\SlimServer\server\CPAN/DBIx/Class/Storage/DBI.pm line 771.

ERROR: Backtrace follows:

Backtrace:

   frame 0: Slim::Schema::Storage::throw_exception (C:\Program Files\SlimServer\server\CPAN/DBIx/Class/Storage/DBI.pm line 773)
   frame 1: DBIx::Class::Storage::DBI::_execute (C:\Program Files\SlimServer\server\CPAN/DBIx/Class/Storage/DBI.pm line 788)
   frame 2: DBIx::Class::Storage::DBI::insert (C:\Program Files\SlimServer\server\CPAN/DBIx/Class/Row.pm line 75)
   frame 3: DBIx::Class::Row::insert (C:\Program Files\SlimServer\server\CPAN/DBIx/Class/PK/Auto.pm line 43)
   frame 4: DBIx::Class::PK::Auto::insert (C:\Program Files\SlimServer\server\CPAN/DBIx/Class/ResultSet.pm line 1335)
   frame 5: DBIx::Class::ResultSet::create (C:\Program Files\SlimServer\server/Slim/Schema/Playlist.pm line 108)
   frame 6: Slim::Schema::Playlist::_addTracksToPlaylist (C:\Program Files\SlimServer\server/Slim/Schema/Playlist.pm line 45)
   frame 7: Slim::Schema::Playlist::__ANON__ (/PerlApp/DBIx/Class/Schema.pm line 584)
   frame 8: (eval) (/PerlApp/DBIx/Class/Schema.pm line 572)
   frame 9: DBIx::Class::Schema::txn_do (C:\Program Files\SlimServer\server/Slim/Schema/Playlist.pm line 46)
   frame 10: (eval) (C:\Program Files\SlimServer\server/Slim/Schema/Playlist.pm line 39)
   frame 11: Slim::Schema::Playlist::setTracks (/PerlApp/Slim/Player/Playlist.pm line 757)
   frame 12: Slim::Player::Playlist::modifyPlaylistCallback (/PerlApp/Slim/Control/Request.pm line 1645)
   frame 13: Slim::Control::Request::notify (/PerlApp/Slim/Control/Request.pm line 751)
   frame 14: Slim::Control::Request::checkNotifications (slimserver.pl line 469)
   frame 15: main::idle (slimserver.pl line 35)
   frame 16: PerlSvc::Startup (perlsvc.pl line 1482)
   frame 17: PerlSvc::_startup (slimserver.pl line 0)
   frame 18: (eval) (slimserver.pl line 0)

ERROR: Carp::Clan::__ANON__(): Error executing 'INSERT INTO playlist_track (playlist, position, track) VALUES (?, ?, ?)': DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`slimserver/playlist_track`, CONSTRAINT `playlist_track_ibfk_1` FOREIGN KEY (`track`) REFERENCES `tracks` (`id`) ON DELETE CASCADE) at C:\Program Files\SlimServer\server\CPAN/DBIx/Class/Storage/DBI.pm line 771.

ERROR: Backtrace follows:

Backtrace:

   frame 0: Slim::Schema::throw_exception (/PerlApp/DBIx/Class/Schema.pm line 606)
   frame 1: DBIx::Class::Schema::txn_do (C:\Program Files\SlimServer\server/Slim/Schema/Playlist.pm line 46)
   frame 2: (eval) (C:\Program Files\SlimServer\server/Slim/Schema/Playlist.pm line 39)
   frame 3: Slim::Schema::Playlist::setTracks (/PerlApp/Slim/Player/Playlist.pm line 757)
   frame 4: Slim::Player::Playlist::modifyPlaylistCallback (/PerlApp/Slim/Control/Request.pm line 1645)
   frame 5: Slim::Control::Request::notify (/PerlApp/Slim/Control/Request.pm line 751)
   frame 6: Slim::Control::Request::checkNotifications (slimserver.pl line 469)
   frame 7: main::idle (slimserver.pl line 35)
   frame 8: PerlSvc::Startup (perlsvc.pl line 1482)
   frame 9: PerlSvc::_startup (slimserver.pl line 0)
   frame 10: (eval) (slimserver.pl line 0)

[F:\My Music\AC-DC\Back In Black\01 Hells Bells.flac] does not exist or cannot be read: No such file or directory at C:\Program Files\SlimServer\server\lib/Audio/FLAC/Header.pm line 59.
ERROR: Couldn't open file: [F:\My Music\AC-DC\Back In Black\01 Hells Bells.flac] for reading: Bad file descriptor
Comment 6 jeff 2006-11-07 05:20:35 UTC
Additional information FWIW. 

After reproducing the problem to create an empty album I powered up the USB drive (album still showed zero songs when navigating to it via Artists--Albums) and rescanned the music library using the "Look for new and changed music" option.  

It correctly picked up all songs on the album except for the first song. 

I then browsed to the album via the music folder and selected the first song and now all songs are correctly displayed under the album.  
Comment 7 Chris Owens 2006-11-09 15:51:32 UTC
Created attachment 1705 [details]
set of mp3s in directories with tags

Well I STILL can't repro your exact symptoms, but at least I can reproduce something that seems almost certainly related, and maybe that will be good enough.

Just to recap the instructions:

1) unzip the attached tiny MP3 files onto a USB drive, maintaining the directory structure.
2) Set the music folder to be [drive letter of the USB drive]\My Music
3) Clear and rescan everything to populate the database correctly
4) Remove the USB drive
5) Using the player UI, browse to one of the tracks and play it.
6) Note a duplicate track will appear in the database with no album information listed.
Comment 8 Chris Owens 2006-11-09 15:52:12 UTC
Dan would you like me to also to test this against the 7.0 build?
Comment 9 Dan Sully 2006-11-09 16:17:03 UTC
Subject: Re:  If music library unavailable duplicate album entries created

Please.

Comment 10 Michael Herger 2007-12-21 06:53:16 UTC
Please :-)
Comment 11 KDF 2008-01-25 11:12:13 UTC
anything? ...Bueller?
Comment 12 Blackketter Dean 2008-01-25 22:06:53 UTC
QA: Please test against 7.0
Comment 13 Blackketter Dean 2008-01-28 10:23:50 UTC
Ross, can you take a look at this?
Comment 14 Ross Levine 2008-01-28 18:01:46 UTC
Reproduced with SC7 - 16819 using steps in comment #2, and seeing the exact same result of a duplicate album. 
Comment 15 jeff 2008-01-29 09:56:35 UTC
I note the target is version 7.1. This just happened to me again two days ago and required a new scan to fix. I presume this means no hope for a fix in 7.0? 
Comment 16 Jim McAtee 2008-01-29 11:01:18 UTC
Very closely related to bug 5067.  SqueezeCenter is fundamentally flawed in how it deals with library storage that goes offline.  Someday I hope we can just turn this behavior off and never have to worry about it again.
Comment 17 Andy Grundman 2008-06-17 13:44:49 UTC
*** Bug 5067 has been marked as a duplicate of this bug. ***
Comment 18 Andy Grundman 2008-06-18 06:36:17 UTC
I've checked in a fix for 2 issues as 7.1 change 20878:

On Windows/Mac, detect if a file is located on offline storage:
* Stats the drive letter on Windows.
* Checks if file is under /Volumes/foo and stats /Volumes/foo

I'm not sure how to properly determine if a file is on an offline filesystem on Linux.  Anybody have any ideas?

The other part I fixed was after auto-deleting files that get moved or deleted (when not on offline storage), a new bogus track entry was being created due to guessTags.  This is now fixed and those entries shouldn't be created anymore.
Comment 19 Chris Owens 2008-07-30 15:26:31 UTC
This bug has now been fixed in the 7.1 release version of SqueezeCenter!  Please download the new version from http://www.slimdevices.com if you haven't already.  

If you are still experiencing this problem, feel free to reopen the bug with your new comments and we'll have another look.
Comment 20 Chris Owens 2009-07-31 10:14:05 UTC
Reduce number of active targets for SC