When i run any yum command on a server it get stuck for ever.
I run yum with strace
strace yum clean
It get stuck with following message from strace
stat("/var/lib/rpm", {st_mode=S_IFDIR|0755, st_size=263, ...}) = 0 rt_sigaction(SIGHUP, NULL, {SIG_DFL, [], 0}, 8) = 0 rt_sigaction(SIGHUP, {0x7f0d6bb15720, [], SA_RESTORER|SA_SIGINFO, 0x7f0d73ba3370}, {SIG_DFL, [], 0}, 8) = 0 rt_sigaction(SIGINT, NULL, {0x7f0d73ec6420, [], SA_RESTORER, 0x7f0d73ba3370}, 8) = 0 rt_sigaction(SIGINT, {0x7f0d6bb15720, [], SA_RESTORER|SA_SIGINFO, 0x7f0d73ba3370}, {0x7f0d73ec6420, [], SA_RESTORER, 0x7f0d73ba3370}, 8) = 0 rt_sigaction(SIGTERM, NULL, {SIG_DFL, [], 0}, 8) = 0 rt_sigaction(SIGTERM, {0x7f0d6bb15720, [], SA_RESTORER|SA_SIGINFO, 0x7f0d73ba3370}, {SIG_DFL, [], 0}, 8) = 0 rt_sigaction(SIGQUIT, NULL, {0x7f0d73ec6420, [], SA_RESTORER, 0x7f0d73ba3370}, 8) = 0 rt_sigaction(SIGQUIT, {0x7f0d6bb15720, [], SA_RESTORER|SA_SIGINFO, 0x7f0d73ba3370}, {0x7f0d73ec6420, [], SA_RESTORER, 0x7f0d73ba3370}, 8) = 0 rt_sigaction(SIGPIPE, NULL, {SIG_IGN, [], SA_RESTORER, 0x7f0d73ba3370}, 8) = 0 open("/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) = 3 read(3, "0-7\n", 8192) = 4 close(3) = 0 umask(022) = 022 open("/var/lib/rpm/.dbenv.lock", O_RDWR|O_CREAT, 0644) = 3 umask(022) = 022 fcntl(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}^CProcess 3102 detached
Got it fixed by deleting the lock files.
rm -f /var/lib/rpm/.dbenv.lock
See yum