Mediascanner-service-2 process is killing HD and consumes lot of CPU

Bug #1294303 reported by ionash.
94
This bug affects 22 people
Affects Status Importance Assigned to Milestone
mediascanner2
Fix Released
Undecided
Unassigned
mediascanner2 (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

I just connected external USB harddrive, when mediascanner-service-2 start scanning (?) over 15 min - even after unplug USB HD. CPU usage was very high (min 50%, sometimes 100%).

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: mediascanner2.0 0.100+14.04.20140314-0ubuntu1
ProcVersionSignature: Ubuntu 3.13.0-18.38-generic 3.13.6
Uname: Linux 3.13.0-18-generic i686
ApportVersion: 2.13.3-0ubuntu1
Architecture: i386
CurrentDesktop: Unity
Date: Tue Mar 18 20:06:06 2014
SourcePackage: mediascanner2
UpgradeStatus: Upgraded to trusty on 2013-11-26 (111 days ago)

Related branches

Revision history for this message
ionash. (janusz-arch) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mediascanner2 (Ubuntu):
status: New → Confirmed
Revision history for this message
Laurens Bosscher (laurens-laurensbosscher) wrote :

I'm also running into problems where media-scanner-service-2.0 consumes 100% cpu all the time. I removed the package for the time being.

Changed in mediascanner2 (Ubuntu):
importance: Undecided → Medium
Changed in mediascanner2:
status: New → Confirmed
Changed in mediascanner2 (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
petrus (steur-petrus5) wrote :

status: New → Confirmed

For now just do :

sudo chmod -x mediascanner-service-2.0

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

How large is the hard drive and how many media files does it have?

Revision history for this message
ionash. (janusz-arch) wrote :

@Jussi Pakkanen
1 TB, 665,5 GB used, 43194 files.

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

That log file indicates that you might be missing some codecs, because some of your mp3 files fail on indexing. You might want to install gstreamer1.0 plugin packages "bad" and/or "ugly".

The fact that Mediascanner keeps using CPU even though a volume is unmounted should be fixed by this branch: https://code.launchpad.net/~jpakkane/mediascanner2/generator/+merge/217426

For general CPU usage there is not much we can do. Mediascanner must scan the files or they can't be queried by the music scope or the music player app. Inspecting tens of thousands of files takes its time, unfortunately. It should be noted, though, that it is only slow the first time. Mediascanner remembers what files you had on the volume and the next time you plug it in it only scans what has changed.

I guess we could add a way for users to tell Mediascanner not to scan certain directories, such as by writing an empty file called .donotscan in directories that should be omitted.

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

The linked branch allows you to tell Mediascanner to not scan the specified directories by creating a .nomedia file. This is the same behaviour as Android has.

Revision history for this message
ionash. (janusz-arch) wrote :

"That log file indicates that you might be missing some codecs, because some of your mp3 files fail on indexing. You might want to install gstreamer1.0 plugin packages "bad" and/or "ugly"."

I have those packages installed since always.

"Mediascanner must scan the files or they can't be queried by the music scope or the music player app."

Since I never truly used Music Scope, (not even believe it to be useful for me) uninstall Mediascanner was a better solution - of course in my case.

"Mediascanner remembers what files you had on the volume and the next time you plug it in it only scans what has changed."

Actually Mediascanner never properly scanned my internal hard drive (before uninstalling, of course), so Music Scope showed only a few files from my collection.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package mediascanner2 - 0.101+14.10.20140530-0ubuntu1

---------------
mediascanner2 (0.101+14.10.20140530-0ubuntu1) utopic; urgency=low

  [ James Henstridge ]
  * Get rid of the direct constructor for MediaFile, forcing creation to
    go through MediaFileBuilder (which won't break when we add more
    metadata fields).
    Also move MediaFile fields to a private struct to avoid breaking ABI
    in future when adding new metadata fields.
  * Add a D-Bus service exposing the MediaStore, and move the QML binding
    over to using it.
  * Limit access to the MediaScanner D-Bus interface from confined
    processes.
    The trust-store API does not exist yet, so it just hard codes support
    for the "com.ubuntu.music" application.
  * Introduce a mediascanner::Filter type to hold search parameters for
    the various MediaStore::list*() methods, and expand them to handle
    genres. The new API also distinguishes between an unset filter and
    a filter set to "". Make similar changes to the QML API, and add
    notify signals to the rowCount properties.
    (LP: #1319168, LP: #1319174).

  [ Jussi Pakkanen ]
  * Add support for .nomedia files to prevent chosen subtrees from being
    scanned. (LP: #1294303).
  * Fix a few warnings emitted by clang.
  * Guard against empty MediaFileBuilders.
  * Fix CMake Project name.
  * Prune those files that have a scan block file on their path when
    restoring.
 -- Ubuntu daily release <email address hidden> Fri, 30 May 2014 07:29:07 +0000

Changed in mediascanner2 (Ubuntu):
status: Triaged → Fix Released
Changed in mediascanner2:
status: Confirmed → Fix Released
Revision history for this message
eris23 (jdkatz23) wrote :

I'm getting what seems to be this problem with utopic amd64. mediascanner2.0 0.105+14.10.20140909-0ubuntu1.

Revision history for this message
eris23 (jdkatz23) wrote :

I should add that I don't want to uninstall mediascanner2 because ubuntu-sdk depends to it (through ubuntu-sdk-libs which depends on qtdeclarative5-ubuntu-mediascanner0.1which depends on mediascanner2.0).

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

To prevent Mediascanner from scanning files on an external hd, add a .nomedia file as described in comment 8.

It will also be slow to scan only the first time. Once it has scanned the directories, it caches the results and does not do it again, even if you unplug and replug your drive.

Revision history for this message
Jussi Lind (jussi-lind) wrote :

mediascanner-service is consuming a lot of CPU time (50%-100%) also on my Bq Aquarius and it must affect the battery life.

Revision history for this message
Jussi Lind (jussi-lind) wrote :

Addition to my previous comment: mediascanner-service constantly consumes up to 100% of CPU time on Bq Aquarius and it WON'T STOP.

Revision history for this message
Luís de Sousa (luis-de-sousa) wrote :

I am running Ubuntu 14.04 fully updated. If left installed, mediascanner2.0 will at some point consume 100% of at least one core and multiply the access time to any HDD by a factor of five or more. Here is a thread from February at AskUbuntu:

http://askubuntu.com/q/587489/177437

Revision history for this message
Cédric Bellegarde (gnumdk) wrote :
Revision history for this message
Cédric Bellegarde (gnumdk) wrote :

Extracting metadata from /home/phablet/Music/6-Let's go (feat. Takana Zion).mp3.

(mediascanner-service-2.0:3806): GStreamer-CRITICAL **: gst_date_time_new: assertion 'year > 0 && year <= 9999' failed

(mediascanner-service-2.0:3806): GStreamer-CRITICAL **: gst_mini_object_unref: assertion 'mini_object != NULL' failed

(mediascanner-service-2.0:3806): GStreamer-CRITICAL **: gst_date_time_to_iso8601_string: assertion 'datetime != NULL' failed
terminate called after throwing an instance of 'std::logic_error'
  what(): basic_string::_S_construct null not valid
Aborted (core dumped)

Revision history for this message
Cédric Bellegarde (gnumdk) wrote :

On Ubuntu 15.04 for pc i do not get:
terminate called after throwing an instance of 'std::logic_error'

Revision history for this message
Cédric Bellegarde (gnumdk) wrote :

Seems because year is -1 in tags

Revision history for this message
Cédric Bellegarde (gnumdk) wrote :

Fixing tags fix issue

But should be fixed in code

Revision history for this message
ITEAS (info-tux-pc) wrote :

Still exists on 14.04 ;(

Revision history for this message
James Henstridge (jamesh) wrote :

To everyone: please file new bugs rather than adding to bug reports that have been closed for more than a year.

Cederic: your specific problem sounds a lot like bug 1436110, which was fixed in the 20150604 build.

To others: mediascanner2 was a pretty young code base during the 14.04 time frame, and we haven't done any back ports since then. It is not a dependency of the base desktop, so it is probably easiest to just uninstall it there.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers