Bug 2369519

Summary: Low disk space causes self-inflicted "soft deadlock" on malformed /usr/lib/sysimage/libdnf5/nevras.toml
Product: [Fedora] Fedora Reporter: Jan Pokorný <pokorny_jan>
Component: dnf5Assignee: rpm-software-management
Status: CLOSED DUPLICATE QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: jonathan, nsella, pkratoch, ppisar, rpm-software-management
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2025-06-02 15:04:25 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jan Pokorný 2025-05-30 21:37:41 UTC
Happened to me on live distro:

```console
# dnf --setopt=cachedir=/tmp/dnfcache remove somepackage
Loading system state TOML file /usr/lib/sysimage/libdnf5/nevras.toml failed (see dnf5-system-state(7)): [error] bad format: unknown value appeared
 --> /usr/lib/sysimage/libdnf5/nevras.toml
      |
 1669 | ... -3.fc41.x86_64" = {from_repo =
      |                                   ^-- here
[error] toml::parse_inline_table: missing closing bracket `}`
 --> /usr/lib/sysimage/libdnf5/nevras.toml
      |
 1669 | ... -3.fc41.x86_64" = {from_repo =
      |                                   ^-- expected `}`, reached line end
```

Apparently, it is vital for that file to always be in consistent
state, written in full or not at all/former version retained.

This situation is also likely not solvable by the means of dnf
proper such as with a subcommand to reconcile the state, or even
with some automatic resolution (consult RPM DB?).

Reproducible: Always




Additional Information:
```console
# rpm -qf /usr/lib/sysimage/libdnf5/nevras.toml
dnf5-5.2.11.0-1.fc43.x86_64
```

Comment 1 Jan Pokorný 2025-05-30 21:41:48 UTC
Could `renameat2(,,,,RENAME_EXCHANGE)` possibly help?

Comment 2 Petr Pisar 2025-06-02 15:04:25 UTC

*** This bug has been marked as a duplicate of bug 2330306 ***