Stale DNF metadata cache in Rocky Linux: diagnosing repodata freshness and expiry defaults
0 reputation · 08 Feb 2022, 02:49 UTC
0 reputation · 08 Feb 2022, 02:49 UTC
Rocky Linux ships DNF (DNF4 on releases 8 and 9) with per-repository metadata cached on disk, and that cache can go stale relative to mirror content. The symptom pattern needing diagnosis: package lookups or downloads can fail with HTTP 404 errors or metadata download failures when cached repomd or primary data still references package files or checksums a mirror has since pruned or replaced, for example during a point-release sync.
Two factors complicate the picture. Rocky content is spread across many mirrors with varying sync lag, and DNF selects a mirror without cross-mirror consistency checks, so a stale cache combined with a lagging mirror can produce intermittent, non-deterministic failures that resemble flaky infrastructure. Separately, Rocky's shipped .repo files generally leave expiry to DNF's compiled default rather than pinning metadata_expire per repository, so the effective cache lifetime can shift with DNF defaults across major versions; defaults also differ between DNF4 and DNF5.
Assuming Rocky 8/9-era DNF4 behavior, three questions need resolution:
metadata_expire default for DNF4 on Rocky 8/9, and how is it confirmed on an installed system?metadata_expire be pinned per repository in /etc/yum.repos.d to balance freshness against mirror load, or left to DNF defaults?33775 reputation · 08 Feb 2022, 03:24 UTC
In Rocky Linux 8 and 9, DNF4 typically defaults to a metadata_expire value of 48 hours when not explicitly defined in the repository configuration. This means DNF will not attempt to refresh the repomd.xml from the mirror unless the local cache is older than this threshold.
Because the default is often compiled into the DNF binary rather than written in the .repo files, you can confirm the current status and expiration of your active repositories using the following command:
dnf repolist -v
Look for the Expiry field in the output for each repository. This indicates when DNF next considers the local metadata stale. Additionally, you can verify the physical age of the cached metadata by checking the timestamps in the DNF cache directory:
ls -l /var/cache/dnf/
Whether to pin metadata_expire in /etc/yum.repos.d/ depends on your environment's stability requirements:
metadata_expire=3600 (1 hour) ensures freshness but increases mirror traffic.Intermittent 404 errors during package downloads are often confused with stale metadata. You can distinguish between a local cache issue and a remote mirror synchronization lag using this logic:
dnf clean expire-cache. This removes only the metadata that has expired, forcing DNF to fetch the latest repomd.xml.Diagnostic Note: To provide a more specific recommendation, please clarify if you are using a local mirror/satellite server or connecting directly to the public Rocky Linux mirror list.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.