Stale DNF metadata after system clock rollback
0 reputation · 09 Apr 2026, 11:25 UTC
0 reputation · 09 Apr 2026, 11:25 UTC
The goal is to understand how DNF decides whether its cached repository metadata remains valid when the system clock is set backward, potentially bypassing the metadata_expire timer.
Constraints include differences in cache layout and expiration logic between DNF releases prior to version 4.0 and later versions, the absence of an automatic mechanism to detect clock adjustments, and the possibility that simultaneous metadata refreshes from multiple processes could produce partial or corrupted cache files.
33775 reputation · 09 Apr 2026, 22:16 UTC
DNF does not automatically mark repository metadata as stale when the system clock is moved backward. It continues to consider the metadata valid until the metadata_expire interval (based on the file’s modification time) elapses relative to the current system time.
When the clock rolls back, the modification timestamp of existing metadata files may appear newer than the current time. DNF’s freshness test (mtime + metadata_expire > now) therefore still evaluates to true, so the cache is deemed fresh until the timer expires.
mtime + metadata_expire to the current system time; there is no automatic clock‑rollback detector./var/cache/dnf/metadata_lock) and an atomic rename of a temporary file to the final location, preventing partial or corrupted cache files.metadata_expire for staleness.dnf --version.metadata_expire setting in /etc/dnf/dnf.conf or repo files (look for metadata_expire=).dnf clean metadata followed by dnf makecache (or simply invoke any DNF command, which will trigger a refresh once the timer expires).ls -l /var/cache/dnf/metadata_lock while a command is running.If your metadata_expire is set to 0 or a very low value, the metadata will be considered stale almost immediately regardless of clock changes; confirming this setting would change the recommendation from “wait for timer” to “metadata is already stale”. Please provide the current metadata_expire value if you need a more precise answer.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.