Sometimes my internet speed becomes slow when I use Fedora after a system reboot. Once this happens, I experienced the effect even though all the network related applications are closed. My internet connection is not a super fast, so it annoyed me a lot. I wanted to find out the reason behind this issue.
Step 1: use netstat to identify the PID/applications which have opened TCP connections,
[root@desktop9 ~]# netstat -anp -t
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.0.1:53 0.0.0.0:* LISTEN 1252/dnsmasq
tcp 13 0 192.168.1.9:48208 192.168.1.50:445 CLOSE_WAIT 6776/gvfsd-smb
tcp 0 0 192.168.1.9:44632 137.189.4.14:80 ESTABLISHED 10934/python
tcp 0 0 192.168.1.9:44635 137.189.4.14:80 CLOSE_WAIT 10934/python
tcp 0 0 192.168.1.9:44690 137.189.4.14:80 CLOSE_WAIT 10934/python
tcp 13 0 192.168.1.9:36304 192.168.1.50:139 CLOSE_WAIT 6769/gvfsd-smb-brow
The output shows that the process 10934/python has a established connection with destination 137.189.4.14:80.
Step 2: Use ps command to find out more information of this process
[root@desktop9 ~]# ps -efw | grep 10934
root 10934 1 0 18:56 ? 00:00:00 /usr/bin/python -OO /usr/bin/dnf -v makecache timer
root 11204 11153 0 19:02 pts/0 00:00:00 grep --color=auto 10934
The output shows the culprit. it was "/usr/bin/dnf -v makecache timer"
The man page of dnf describes makecache downloads and caches in binary format metadata for all known repos available in the system.
Man page output:
dnf [options] makecache
Downloads and caches in binary format metadata for all known repos. Tries to avoid downloading whenever possible (e.g. when the local metadata
hasn't expired yet or when the metadata timestamp hasn't changed).
dnf [options] makecache timer
Like plain makecache but instructs DNF to be more resource-aware, meaning will not do anything if running on battery power and will terminate
immediately if it's too soon after the last successful makecache run (see dnf.conf(8), metadata_timer_sync).
It seems that the dnf makecache is scheduled to run after every reboot. I decided to disable this and do manual metadata updates whenever it's required.
Command to disable dnf-makecache.service:
systemctl disable dnf-makecache.service
Update 1: Disable the dnf-makecache.timer as well. Otherwise the service will be restarted.
systemctl disable dnf-makecache.timer
Update 2: I started using Fedora 29 Server edition and noted packagekit is also involved in this.
Therefore I disabled them as well,
systemctl disable packagekit.service
systemctl disable packagekit-offline-update.service
In my case, dnf makecache was stuck for several hours and didn't know if I could stop it.
ReplyDeleteSo, your post was indeed useful! Thanks!
Important recommendation, thanks. I identified "Started dnf makecache" in /var/log/messages as repeating reason of Fedora 23 hangs. When you look at this disputation: "https://bugzilla.redhat.com/show_bug.cgi?id=1187111" you start to understand why Bugzilla is missing its target for Fedora. Egos are for more guys more than reality, facts and findings. How many Fedora users will have to fight with a nonsense of unneeded dnf cache update hanging whole system? Hynek
ReplyDeletesystemctl disable packagekit doesn't work
ReplyDeleteFor further use you should do this:
systemctl mask packagekit
Useful, thanks!
ReplyDelete