Bug 17482 - CLI: "info total tracks/albums/artists" counts are not coherent with actual music database
: CLI: "info total tracks/albums/artists" counts are not coherent with actual m...
Status: RESOLVED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: CLI
: 7.6.0
: Infrant ReadyNAS RAIDiator (SPARC)
: P3 normal (vote)
: 7.6.x
Assigned To: Michael Herger
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-21 08:54 UTC by Kristian Walsh
Modified: 2011-09-02 04:47 UTC (History)
0 users

See Also:
Category: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kristian Walsh 2011-08-21 08:54:55 UTC
Details
------
When songs are added to the library using the "browse music folder" method, these songs are not counted in the 'info total songs' (and 'total albums' etc) commands on the CLI.

The only way to accurately determine the number of songs is to issue a 'songs 0 0' command, which has serious performance issues.

Reproduction
------------

0. Create new library with 4 albums and 10 files in each (figures are not significant - for example only)
1. Add music files for a new album with 10 tracks to the server's music directory 
1a. DO NOT PERFORM A RE-SCAN
2. Go to player interface > Music Folder > (navigate to new files) >
[ the new files are now added to the library ]

We should now have 5 albums, 5 artists, and 50 songs.


Telnet to CLI:

> serverstatus
serverstatus  
 lastscan:<whenever>
 version:7.6.0
 uuid:<blah>
 info total albums:4
 info total artists:4
 info total genres:1
 info total songs:40
 player count:1
 sn player count:0
 other player count:0

### Note that the "info total..." fields no longer concur with true state of DB.

### But...

> songs 0 1
songs 0 1 <track info tags here> count:50 

>info total songs ?
info total songs 40

> albums 0 1
albums 0 1 <album info tags here> count:5

> artists 0 1
artists 0 1 <artist info tags here> count:5


The tracks/albums/artists queries perform a SQL query, so they reflect the true state of the library.  It seems that "info total XXX" is using a cached value.


Workaround
-----------
The appalling performance of the 'songs xxx' command when not restricted to an album id makes it a poor workaround for 'info  total songs' being wrong, but using it is the only way to ensure the correct information is retrieved.

For my 6000 song database, the 'songs 0 1' command takes 14 seconds to complete.  Even the no-brainer "songs 0 0" takes 7 seconds. It seems that the entire record set is being joined, sorted, and finally limited to zero length.   (an aside:  being able to say "sort:none"  would be great on this query!) 


Suggestion
----------
Make 'info total songs' (and, by extension, "serverstatus") perform a "SELECT COUNT( whatever-you've-called-the-primary-key ) FROM songs;" query rather than relying on a cached value, and so on for albums, artists, genre.
Comment 1 SVN Bot 2011-08-22 06:08:21 UTC
 == Auto-comment from SVN commit #33142 to the slim repo by mherger ==
 == http://svn.slimdevices.com/slim?view=revision&revision=33142 ==

Bug: 17482
Description: wipe caches in BMF, as adding single items through BMF wouldn't wipe them, only new/changed folders do
Comment 2 Michael Herger 2011-09-02 04:47:05 UTC
This is fixed in 7.6.2