Affected versions: CentOS Stream 10

📖 ~1 min read

Table of contents
  1. Symptom & Impact
  2. Environment & Reproduction
  3. Root Cause Analysis
  4. Quick Triage
  5. Step-by-Step Diagnosis
  6. Solution – Primary Fix
  7. Solution – Alternative Approaches
  8. Verification & Acceptance Criteria
  9. Rollback Plan
  10. Prevention & Hardening
  11. Related Errors & Cross-Refs
  12. References & Further Reading

Symptom & Impact

Subsequent `dnf` invocations report a lock held by a dead PID, blocking all package operations.

Environment & Reproduction

Common when previous dnf process was killed forcefully or a container exited mid-transaction.

Root Cause Analysis

Stale lock files in /var/lib/rpm and /var/cache/dnf are not cleaned up automatically.

Quick Triage

Quickly list locks with `lsof /var/lib/rpm/.rpm.lock` and `fuser /var/lib/rpm/.rpm.lock`.

Step-by-Step Diagnosis

Confirm no live dnf or rpm process exists, then identify the stale PID in lock metadata.

Illustrative mockup for centos-stream-10 — terminal_or_shell
stale RPM lock file diagnostics in terminal — Illustrative mockup — Progressive Robot

Solution – Primary Fix

Remove the stale lock with `rm -f /var/lib/rpm/.rpm.lock` after verifying no live process holds it.

Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.

Illustrative mockup for centos-stream-10 — logs_or_journal
journal and log evidence for stale RPM lock file — Illustrative mockup — Progressive Robot

Solution – Alternative Approaches

Restart `packagekit` and retry the operation in single-user maintenance.

Verification & Acceptance Criteria

`dnf makecache` and `dnf check-update` complete without lock errors.

Rollback Plan

Restore lock state from backup if filesystem ACLs were inadvertently modified.

Prevention & Hardening

Configure `nice` and `ionice` settings to prevent OOM kills during heavy package operations.

Frequently linked to OOM events and unexpected reboots during upgrade.

Related tutorial: View the step-by-step tutorial for centos-stream-10.

View all centos-stream-10 tutorials on the Tutorials Hub →

Browse all common problems & solutions on the Tutorials Hub.

References & Further Reading

CentOS Stream 10 RPM and dnf locking reference materials.

Need Expert Help?

If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today — we respond within one business day.