Skip to content

Store optimisation hard-links non-identical files, corrupting store #14599

@amarshall

Description

@amarshall

Describe the bug

Files that should not be hard-linked together get hard-linked. In particular for the case I saw, files that should have been empty files (8000+) were hard-linked to a non-empty file.

If I had to guess (and this is just a guess!), there was a race where store optimisation analyzed a file between its creation and having content written to it, and decided to hard-link it to the empty file. Once content was written, all other empty files became non-empty.

Steps to reproduce

Unclear.

Expected behavior

Hard links to only link identical files.

Metadata

nix-env (Nix) 2.31.2 on aarch64-darwin

Additional context

auto-optimise-store is disabled. Store optimisation runs in a scheduled job. nix store repair --all remedied the corrupt files, making them empty again.

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions