Dnf took nearly 100% and system halted

I’ve a system running AlmaLinux release 9.4 (Seafoam Ocelot). And suddenly system halted at 11:37:xx. I captured during I opened a screen for top command( dnf took 99%)


. My system could not take any response until I forced restart.
Here is my captured info:

at dnf log:

Jun 28 11:33:43 localhost systemd[1]: Starting dnf makecache...
Jun 28 11:33:44 localhost dnf[379775]: AlmaLinux 9 - AppStream                          10 kB/s | 4.2 kB     00:00
Jun 28 11:33:44 localhost dnf[379775]: AlmaLinux 9 - BaseOS                            8.8 kB/s | 3.8 kB     00:00
Jun 28 11:33:44 localhost dnf[379775]: AlmaLinux 9 - Extras                            8.0 kB/s | 3.3 kB     00:00
Jun 28 11:33:46 localhost dnf[379775]: Extra Packages for Enterprise Linux 9 - x86_64   10 kB/s |  17 kB     00:01
Jun 28 11:33:48 localhost dnf[379775]: Extra Packages for Enterprise Linux 9 - x86_64   11 MB/s |  21 MB     00:01
Jun 28 11:33:44 myAppServer dnf[379775]: AlmaLinux 9 - BaseOS                            8.8 kB/s | 3.8 kB     00:00
Jun 28 11:33:44 myAppServer dnf[379775]: AlmaLinux 9 - Extras                            8.0 kB/s | 3.3 kB     00:00
Jun 28 11:33:46 myAppServer dnf[379775]: Extra Packages for Enterprise Linux 9 - x86_64   10 kB/s |  17 kB     00:01
Jun 28 11:33:48 myAppServer dnf[379775]: Extra Packages for Enterprise Linux 9 - x86_64   11 MB/s |  21 MB     00:01
Jun 28 11:38:17 myAppServer kernel: Linux version 5.14.0-427.20.1.el9_4.x86_64 (mockbuild@x64-builder02.almalinux.org) (gcc (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3), GNU ld version 2.35.2-43.el9) #1 SMP PREEMPT_DYNAMIC Mon Jun 10 08:04:28 EDT 2024
Jun 28 11:38:17 myAppServer kernel: The list of certified hardware and cloud instances for Red Hat Enterprise Linux 9 can be viewed at the Red Hat Ecosystem Catalog, https://catalog.redhat.com.
Jun 28 11:38:17 myAppServer kernel: Command line: BOOT_IMAGE=(hd0,gpt3)/boot/vmlinuz-5.14.0-427.20.1.el9_4.x86_64 root=UUID=9481d0bf-02a3-4df7-bed5-8c7bdbf8fa06 ro crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M rhgb quiet selinux=0 net.ifnames=0 console=tty0 console=ttyS0,115200n8 nvme_core.io_timeout=4294967295 nvme_core.admin_timeout=4294967295 iommu=pt
Jun 28 11:38:17 myAppServer kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'

at /var/log/message log

2024-06-28T11:33:44+0700 DEBUG Failed to set default SELinux context to "system_u:object_r:user_tmp_t:s0"
2024-06-28T11:33:44+0700 DEBUG reviving: 'extras' can be revived - repomd matches.
2024-06-28T11:33:44+0700 DEBUG extras: using metadata from Fri 28 Jun 2024 05:08:17 AM +07.
2024-06-28T11:33:44+0700 DEBUG Failed to retrieve a default SELinux context
2024-06-28T11:33:45+0700 DEBUG Failed to set default SELinux context to "system_u:object_r:user_tmp_t:s0"
2024-06-28T11:33:45+0700 DEBUG countme: no event for epel: window already counted
2024-06-28T11:33:46+0700 DEBUG reviving: failed for 'epel', mismatched sha256 sum.
2024-06-28T11:33:46+0700 DEBUG repo: downloading from remote: epel
2024-06-28T11:33:46+0700 DEBUG Failed to retrieve a default SELinux context
2024-06-28T11:33:46+0700 DEBUG Failed to set default SELinux context to "system_u:object_r:rpm_var_cache_t:s0"
2024-06-28T11:33:46+0700 DEBUG countme: no event for epel: window already counted
2024-06-28T11:40:41+0700 INFO --- logging initialized ---
2024-06-28T11:40:41+0700 DDEBUG timer: config: 17 ms
2024-06-28T11:40:41+0700 DEBUG Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, kpatch, needs-restarting, notify-packagekit, playground, repoclosure, repodiff, repograph, repomanage, reposync, system-upgrade
2024-06-28T11:40:41+0700 DEBUG DNF version: 4.14.0

Also included picture. Any suggestion/help please.

Similar to my problem, it was caused by memory usage.

After had issue, I’ve assigned swappiness to 15 (default is unset). I also disabled dnf-makecache.timer. Until now there’s no issue.