Bug 140888 - context browser shows "file not in collection" when it is in collection
Summary: context browser shows "file not in collection" when it is in collection
Status: RESOLVED WORKSFORME
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: 1.4-SVN
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-30 14:11 UTC by bonne
Modified: 2007-05-10 20:31 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot of funny behaviour (94.10 KB, image/png)
2007-01-30 14:12 UTC, bonne
Details
SQL to fix offending columns after upgrading mysql 4.1 -> 5.0 (2.63 KB, text/plain)
2007-01-31 03:13 UTC, bonne
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bonne 2007-01-30 14:11:35 UTC
Version:           1.4-SVN (using KDE 3.5.5, Gentoo)
Compiler:          Target: x86_64-pc-linux-gnu
OS:                Linux (x86_64) release 2.6.17-gentoo-r8

As discussed on IRC today I'm having a problem whereby Amarok tells me in the collection browser that "the file is not in  your collection" when clearly it is. 

The full symptoms are: Started amarok after a clean exit yesterday and the collection was empty. Checked the db tables and the tags table was empty. After a rescan everything came back (covers, stats) except that now the warning shows up in the collection browser that the file isn't in the collection. 

I've attached a screenshot showing this along with stats that clearly require the file to be in the collection.

I tried rescanning a few times. 

Any help is appreciated. 

p.s. I just upgraded a few things - mysql, dbus, hal. I'm sure these make the difference but I can't seem to figure it out.
Comment 1 bonne 2007-01-30 14:12:11 UTC
Created attachment 19481 [details]
Screenshot of funny behaviour
Comment 2 bonne 2007-01-30 14:47:28 UTC
I think that the version of mysql I have now has filled all the varchar fields with spaces. 
Comment 3 bonne 2007-01-31 01:17:43 UTC
I switched on full logging for mysql and had a look at the events that were created. 

One of particular interest looks like this:
SELECT url FROM tags WHERE url = './some/url/path/file.mp3';"

It comes from the function CollectionDB::isFileInCollection on line 1435 of database_refactor/collectiondb.cpp

I manually ran the command and it found no rows. 
Changing it to look like this:
SELECT url FROM tags WHERE url REGEXP './some/url/path/file.mp3';"
produces the one expected row. 

The problem is that for some reason the url and dir columns are filled. In mysql 5.0.26 this fill is the \0 character, but it shouldn't be used for VARBINARY fields, only BINARY fields. 

Anyone have any idea why this fill would be there? 

Here is the dev page on VARBINARY from mysql http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html
Comment 4 Alexandre Oliveira 2007-01-31 01:25:47 UTC
Sounds like this mysql bug: http://bugs.mysql.com/bug.php?id=19371
Comment 5 bonne 2007-01-31 03:12:21 UTC
Indeed it is. The problem comes from upgrading 4.1 -> 5.0 
Here's how I recovered from the problem:

1. ALTER TABLE tags ENGINE=myisam
2. Repeat 1 for all the tables
3. UPDATE tags SET url = TRIM(TRAILING '\0' FROM url)
4. Repeat 3 for VARBINARY fields url, dir etc. in all tables. (I excluded the uniqueid columns because they didn't seem padded. Also some of the columns were padded with space)
5. Pour a nice single malt scotch and listen to sweet sweet music. 

I'll attach an sql script that will fix this. 

I haven't yet fully tested this but I have a strong feeling it'll work just fine. 
Comment 6 bonne 2007-01-31 03:13:15 UTC
Created attachment 19489 [details]
SQL to fix offending columns after upgrading mysql 4.1 -> 5.0
Comment 7 bonne 2007-01-31 13:46:43 UTC
This has fixed the problem. 
Comment 8 Kevin Funk 2007-05-10 20:31:50 UTC
Ok, resolving.