Bug 265419 - Empty collection when using remote mysql database
Summary: Empty collection when using remote mysql database
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Collections/Local (show other bugs)
Version: 2.4.1
Platform: Ubuntu Linux
: NOR normal
Target Milestone: 2.4.1
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-04 17:12 UTC by belatu_cadros
Modified: 2012-12-28 19:07 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.7
Sentry Crash Report:


Attachments
Amarok database queries + extra info (1.78 KB, text/plain)
2011-02-06 12:55 UTC, Jari Laurila
Details

Note You need to log in before you can comment on or make changes to this bug.
Description belatu_cadros 2011-02-04 17:12:26 UTC
Version:           2.4.0 (using KDE 4.6.0) 
OS:                Linux

Collection displays 0 tracks in Collection when using a remote mysql database to store a central collection. 

Reproducible: Always

Steps to Reproduce:
1. Share music directories through NFS and mount with same mountpoints on multiple computers
2. Configure amarok to use a central mysql database (same host, user, and database name) on multiple computes
3. Scan collection on 1st computer.
4. Open amarok on 2nd computer

Actual Results:  
Local Collection displays 0 tracks in Local Collection. This behaviour differs from previous versions of amarok. 

Expected Results:  
Local Collection to display all tracks found in scan from 1st computer. All statistics and ratings are shared

If amarok on the 1st computer is closed and restarted, all tracks found in scan are displayed.

Similar behaviour is seen when two computers store their local copies of music in same directory (ie /opt/mp3). This again differs from previous versions of amarok.
Comment 1 Ralf Engels 2011-02-04 18:05:04 UTC
Hi,
you have to be a little careful when two instances of Amarok are using the same database at the same time. The collection might look different. Changes on one Amarok are not automatically displayed in the other one. This behavior is still the same.

That being said, if the scan on computer 1 is finished before you start Amarok on computer 2 an empty collection should not be displayed.
Can you be a little bit more detailed in your description like:
3.5: while scan is running on computer 1..
or
4.5: Change the configuration of the database to the external one

When you write "reproducable always", did you try it twice, killing the database in between?
Comment 2 belatu_cadros 2011-02-04 18:42:20 UTC
To answer your questions

- While the while scan is running on computer 1, I do nothing, I let the scan complete. I have tried both starting amarok on the 2nd computer with and without quitting amarok on the first computer. Both show 0 tracks in the Local Collection on the 2nd computer. 

- On the second computer my home directory is NFS mounted, there is no need to change the configuration to external database on the 2nd. I have also tried on multiple other computers with a local home directory and configuring amarok to the remote mysql database. I get the same result, O tracks in the local collection. In all instances if I start amarok on the 1st computer I can see the full collection.

Other test I have tried include
- dropping and recreating the mysql database before scanning on the 1st computer
- removing any amarok configuration files from ~/.kde/share/amarok before scanning on all computers. After changing from the default to a mysql database, amarok is retarted. 
- both removing config and dropping the database before scanning

All have the same result of 0 tracks in the Local collection on the 2nd computer.
Comment 3 Jari Laurila 2011-02-06 12:55:41 UTC
Created attachment 56914 [details]
Amarok database queries + extra info
Comment 4 Jari Laurila 2011-02-06 13:12:09 UTC
I have similar situation:

I have one one computer which has collection and second computer which uses the same collection through nfs share. Both computers have exactly same path to collection root (/home/stuff/Music). Amaroks Mysql database is also on first computer and only the first computer is allowed to scan collection (Watch folder for changes). First computer is 64bit Arch Linux with KDE 4.6 and Amarok 2.4.0 and the second computer is Ubuntu 10.10 with Amarok 2.4.0 + KDE 4.6 components. 

While I was debugging the problem I noticed that both computers use their own root filesystems uid in queries while they fetch the list of artists and list of albums from database. (I have attached the queries in this report.) Because of this second computer obviously fails to fetch any artists or albums from datbase. (All the artists and albums have deviceid pointing to first computers root filesystem.)
Comment 5 Jari Laurila 2011-02-06 13:30:36 UTC
I managed the create temporary workaround for this..
Run the following query on amarok database:
UPDATE urls SET deviceid=-1
Comment 6 belatu_cadros 2011-02-06 18:06:53 UTC
I can confirm the workaround works for my situation as well.
Comment 7 Ralf Engels 2011-02-07 11:50:15 UTC
Oh, nice.
Thanks for debugging the problem. I will have a look at it.
Comment 8 belatu_cadros 2011-02-07 17:27:54 UTC
It appears the workaround doesn't quite work for the 2nd computer. The collection displays properly but when you attempt to play a track the following error is displayed on the console:

"TagLib: Could not open file /full_albums/a_perfect_circle/thirteenth_step/01_the_package.mp3
TagLib: Could not open file /full_albums/a_perfect_circle/thirteenth_step/01_the_package.mp3"

The full path the file should be /opt/bc/mp3/full_albums/a_perfect_circle/thirteenth_step/01_the_package.mp3
Comment 9 Johannes Midgren 2011-02-16 22:34:40 UTC
I have the same problem but an initial test using the workaround from comment #5 seems to solve the problem for me.

On both computers I use amarok on, I mount my music folder using NFS and I use the same local mount point on both machines.

I'll get back with further comments should the problem reappear.
Comment 10 Johannes Midgren 2011-02-17 23:47:50 UTC
Another thing I noted on the 2nd computer is that even after applying the fix suggested in comment #5, rescanning the mounted NFS share for new music has no effect. The scan proceeds quickly but does not find any newly added music files.

It doesn't matter if I use the global rescan (Tools/Update collection) or if I try to rescan the mounted music folder only (from within the "Configure Amarok" dialogue, right clicking the folder on the Collection pane).
Comment 11 belatu_cadros 2011-03-04 17:29:47 UTC
I had time to do some more investigation on this, it appears dynamic collections from 1.4.x are enabled again. To get the desired behaviour of a shared collection across computers, see the Disabling Dynamic Collection section of http://amarok.kde.org/wiki/Dynamic_Collection
Comment 12 Jari Laurila 2011-03-20 12:40:48 UTC
(In reply to comment #11)
> I had time to do some more investigation on this, it appears dynamic
> collections from 1.4.x are enabled again. To get the desired behaviour of a
> shared collection across computers, see the Disabling Dynamic Collection
> section of http://amarok.kde.org/wiki/Dynamic_Collection

I had finally time to test this. Disabling dynamic collections seemed to work. Now I just have to write sql script to restore the statistics..
Comment 13 Myriam Schweingruber 2011-06-04 12:16:40 UTC
This is an automated message from the triager:

Amarok 2.4.1 has been released on May 8 already. Could you please upgrade and test if you can still reproduce this bug?

Without feedback within a month we will close this bug as resolved.

Thank you for your understanding.
Comment 14 belatu_cadros 2011-06-12 22:07:51 UTC
Issues still exist in Amarok 2.4.1.

Steps used to re-create
1. remove collection section from amarokrc
2. start amarok on computer 1, Set collection directory and do a full rescan.
3. exit amarok on computer 1
4. start amarok on computer 2.
Comment 15 Myriam Schweingruber 2011-06-13 10:57:41 UTC
Thank you for the feedback.
Comment 16 Ralf Engels 2011-06-16 17:16:38 UTC
Cadros,
did you try disabling the dynamic collection as per comment #12?
Comment 17 belatu_cadros 2011-06-16 17:39:01 UTC
Hi Ralf,

After the test in comment #14, I disabled Dynamic collections, dropped the database and rescanned. Unfortunately this no longer worked as I had to used the work around in comment #5 to be able to see my collection on the 2nd computer.
Comment 18 Ralf Engels 2012-12-13 11:47:58 UTC
I will commit a fix for this problem in a minute.
However please notice that Amarok is doing a lot of caching, so if you have two or more Amaroks working on the same database at the same time you might get inconsistencies.
Actually the chance of breaking the database is slim, just be warned.

Also I will update the wiki with some more information.
Comment 19 Matěj Laitl 2012-12-28 19:07:05 UTC
Marking as fixed, strange the commit hood didn't fire, the commit had proper tags..

http://commits.kde.org/amarok/8c7fc3af