记一次莫名其妙的 CPU 100% Bug 排查

问题描述

系统环境CentOS 7.5.1804

tracker-extract CPU 占用率 100%
tracker-extract CPU 占用率 100%

htop查看系统负载,发现其中一个 CPU 长时间处于100%状态,排查后发现罪魁祸首就是/usr/libexec/tracker-extract这个进程。

直接killkill -9后,进程tracker-extract会自动重启,并再次达到CPU 100%

> yum info tracker

Installed Packages
Name        : tracker
Arch        : x86_64
Version     : 1.10.5
Release     : 6.el7
Size        : 5.6 M
Repo        : installed
From repo   : anaconda
Summary     : Desktop-neutral search tool and indexer
URL         : https://wiki.gnome.org/Projects/Tracker
License     : GPLv2+
Description : Tracker is a powerful desktop-neutral first class object database,
            : tag/metadata database, search tool and indexer.
            : 
            : It consists of a common object database that allows entities to have an
            : almost infinite number of properties, metadata (both embedded/harvested as
            : well as user definable), a comprehensive database of keywords/tags and
            : links to other entities.
            : 
            : It provides additional features for file based objects including context
            : linking and audit trails for a file object.
            : 
            : It has the ability to index, store, harvest metadata. retrieve and search
            : all types of files and other first class objects

tracker-extract属于tracker,主要用于桌面索引,下面介绍几种解决办法。

1. 卸载 tracker(不推荐)

最直接的办法,卸载tracker,不过会同时卸载nautilusgnome-classic-session等相关依赖包,不推荐这种方法

> yum info tracker

Installed Packages
Name        : tracker
Arch        : x86_64
Version     : 1.10.5
Release     : 6.el7
Size        : 5.6 M
Repo        : installed
From repo   : anaconda
Summary     : Desktop-neutral search tool and indexer
URL         : https://wiki.gnome.org/Projects/Tracker
License     : GPLv2+
Description : Tracker is a powerful desktop-neutral first class object database,
            : tag/metadata database, search tool and indexer.
            : 
            : It consists of a common object database that allows entities to have an
            : almost infinite number of properties, metadata (both embedded/harvested as
            : well as user definable), a comprehensive database of keywords/tags and
            : links to other entities.
            : 
            : It provides additional features for file based objects including context
            : linking and audit trails for a file object.
            : 
            : It has the ability to index, store, harvest metadata. retrieve and search
            : all types of files and other first class objects

> yum remove tracker
Dependencies Resolved

=================================================================================
 Package                    Arch        Version             Repository      Size
=================================================================================
Removing:
 tracker                    x86_64      1.10.5-6.el7        @anaconda      5.6 M
Removing for dependencies:
 brasero                    x86_64      3.12.1-2.el7        @anaconda       11 M
 brasero-nautilus           x86_64      3.12.1-2.el7        @anaconda       47 k
 evince-nautilus            x86_64      3.22.1-7.el7        @anaconda       19 k
 gnome-boxes                x86_64      3.22.4-4.el7        @anaconda      5.0 M
 gnome-classic-session      noarch      3.26.2-3.el7        @anaconda      199 k
 grilo-plugins              x86_64      0.3.4-3.el7         @anaconda      2.1 M
 nautilus                   x86_64      3.22.3-5.el7        @anaconda       15 M
 totem                      x86_64      1:3.22.1-1.el7      @anaconda      6.3 M
 totem-nautilus             x86_64      1:3.22.1-1.el7      @anaconda       36 k
 tracker-preferences        x86_64      1.10.5-6.el7        @base          248 k

Transaction Summary
=================================================================================
Remove  1 Package (+10 Dependent packages)

Installed size: 45 M
Is this ok [y/N]: n

2. tracker daemon -k(暂时性)

暂时性的方法,调用tracker daemon -k杀死所有tracker相关进程

> tracker
usage: tracker [--version] [--help]
               <command> [<args>]

Available tracker commands are:
   daemon    Start, stop, pause and list processes responsible for indexing content
   extract   Extract information from a file
   info      Show information known about local files or items indexed
   index     Backup, restore, import and (re)index by MIME type or file name
   reset     Reset or remove index and revert configurations to defaults
   search    Search for content indexed or show content by type
   sparql    Query and update the index using SPARQL or search, list and tree the ontology
   sql       Query the database at the lowest level using SQL
   status    Show the indexing progress, content statistics and index state
   tag       Create, list or delete tags for indexed content

See 'tracker help <command>' to read about a specific subcommand.

> tracker daemon -k all
Found 10 PIDs…
  Killed process 2390 - 'tracker-miner-user-guides'
  Killed process 2395 - 'tracker-store'
  Killed process 2656 - 'tracker-miner-apps'
  Killed process 2705 - 'tracker-miner-fs'
  Killed process 2952 - 'tracker-miner-user-guides'
  Killed process 2962 - 'tracker-extract'
  Killed process 2963 - 'tracker-miner-apps'
  Killed process 2964 - 'tracker-miner-fs'
  Killed process 2987 - 'tracker-store'
  Killed process 13666 - 'tracker-extract'

可通过tracker daemon -s重新启动tracker相关进程

3. 禁用 tracker 的 autostart

/etc/xdg/autostart/tracker*.desktop文件的末尾添加以下内容:

Hidden=true

注销后重新登录生效

4. 安装 tracker-preferences

> yum info tracker-preferences
Available Packages
Name        : tracker-preferences
Arch        : x86_64
Version     : 1.10.5
Release     : 6.el7
Size        : 58 k
Repo        : base/7/x86_64
Summary     : Tracker preferences
URL         : https://wiki.gnome.org/Projects/Tracker
License     : GPLv2+
Description : Graphical frontend to tracker configuration.

> yum install tracker-preferences
tracker-preferences
tracker-preferences

打勾的选项全部取消,注销后重新登录生效

参考文章

  1. tracker-extract high cpu usage | StackExchange
  2. tracker-extract process with 100% cpu usage | CentOS
  3. [Solved] How to disable tracker-store processes that eat 100% CPU | openSUSE Forum
  4. Ubuntu Gnome 14.04 tracker-extract 占用内存太高 | CSDN
  5. 解决 Linux 中 tracker 大量占用 CPU 的问题 | Linux 公社
  6. Ubuntu 16.04 莫名其妙占用 CPU 的 tracker | Paulus.Chen