[Nix#9548] Potential race condition between nix-store --gc and nix-build #90

Open
opened 2024-03-16 06:44:51 +00:00 by lix-bot · 0 comments
Member

Upstream-Issue: NixOS/nix#9548

Describe the bug

In an attempt to run home-manager --flake . switch to build a new home-manager-generation while nix-store --gc is running, I got the following outputs;

(The trace message about unfree and insecure packages are added by my allow{Unfree,Insecure}Predicate in my configuration.nix.)

nixpkgs on  home-manager-config [$] took 6s
❯ home-manager --flake . switch
warning: error: SQLite database '/nix/var/nix/db/db.sqlite' is busy
trace: Unfree package unrar found.
trace: Unfree package webex found.
trace: Unfree package zoom found.
trace: Unfree package steam-run found.
trace: Unfree package steam-original found.
trace: Unfree package sublimetext4 found.
trace: Insecure package openssl 1.1.1w found.
warning: error: SQLite database '/nix/var/nix/db/db.sqlite' is busy
trace: Unfree package skypeforlinux found.
trace: Unfree package vscode-extension-ms-vscode-cpptools found.
trace: Unfree package vscode-extension-mhutchie-git-graph found.
trace: Unfree package vscode-extension-MS-vsliveshare-vsliveshare found.
trace: Unfree package vscode-extension-MS-vsliveshare-vsliveshare-audio found.
error:
       … while calling the 'derivationStrict' builtin

         at //builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'home-manager-generation'
         whose name attribute is located at /nix/store/6yb90vdnzwb84kgbjik6kpaw0m6gfcxd-source/pkgs/stdenv/generic/make-derivation.nix:303:7

       … while evaluating attribute 'buildCommand' of derivation 'home-manager-generation'

         at /nix/store/6yb90vdnzwb84kgbjik6kpaw0m6gfcxd-source/pkgs/build-support/trivial-builders/default.nix:87:14:

           86|       enableParallelBuilding = true;
           87|       inherit buildCommand name;
             |              ^
           88|       passAsFile = [ "buildCommand" ]

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: getting status of '/nix/store/xl229jfp80rpw7jymzaf87wsh4wylg28-source': No such file or directory

If you have a problem with a specific package or NixOS,
you probably want to file an issue at https://github.com/NixOS/nixpkgs/issues.

Steps To Reproduce

I don't know how to reproduce this. Here's what I did before it occurs:

  1. Run nix-store --gc because of disk space outage.
  2. Wait for about a minute to tens of GiBs of disk space
  3. Open another terminal emulator
  4. Run cd .config/nixos, the directory of the Home Manager Configuration flake.
  5. Run home-manager --flake . switch
  6. See the evaluation proceeds, while complaining warning: error: SQLite database '/nix/var/nix/db/db.sqlite' is busy twice
  7. See the evaluation finishes and the build starts. Packages are fetched from the binary cache.
  8. See something gets build.
  9. See the error complaining about the missing store path.

Expected behavior

In the multi-user Nix installation, the users expect Nix to prevent race condition when nix-store --gc and nix-build is run by different processes or even different users. This should not be at the expense of a full blockage of nix-build during the nix-store --gc execution.

nix-env --version output
nix-env (Nix) 2.15.2

Additional context

nix-info -m output:

  • system: "x86_64-linux"
  • host os: Linux 6.1.55, NixOS, 23.05 (Stoat), 23.05.20231007.5a237ae
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.15.2
  • nixpkgs: /nix/store/hwqz0b3d0wcyjvb4fda1wf8lhj4vaa4m-source

Add any other context about the problem here.

Priorities

Add 👍 to issues you find important.

Upstream-Issue: https://git.lix.systems/NixOS/nix/issues/9548 **Describe the bug** In an attempt to run `home-manager --flake . switch` to build a new `home-manager-generation` while `nix-store --gc` is running, I got the following outputs; (The trace message about unfree and insecure packages are added by my `allow{Unfree,Insecure}Predicate` in my `configuration.nix`.) ``` nixpkgs on  home-manager-config [$] took 6s ❯ home-manager --flake . switch warning: error: SQLite database '/nix/var/nix/db/db.sqlite' is busy trace: Unfree package unrar found. trace: Unfree package webex found. trace: Unfree package zoom found. trace: Unfree package steam-run found. trace: Unfree package steam-original found. trace: Unfree package sublimetext4 found. trace: Insecure package openssl 1.1.1w found. warning: error: SQLite database '/nix/var/nix/db/db.sqlite' is busy trace: Unfree package skypeforlinux found. trace: Unfree package vscode-extension-ms-vscode-cpptools found. trace: Unfree package vscode-extension-mhutchie-git-graph found. trace: Unfree package vscode-extension-MS-vsliveshare-vsliveshare found. trace: Unfree package vscode-extension-MS-vsliveshare-vsliveshare-audio found. error: … while calling the 'derivationStrict' builtin at //builtin/derivation.nix:9:12: (source not available) … while evaluating derivation 'home-manager-generation' whose name attribute is located at /nix/store/6yb90vdnzwb84kgbjik6kpaw0m6gfcxd-source/pkgs/stdenv/generic/make-derivation.nix:303:7 … while evaluating attribute 'buildCommand' of derivation 'home-manager-generation' at /nix/store/6yb90vdnzwb84kgbjik6kpaw0m6gfcxd-source/pkgs/build-support/trivial-builders/default.nix:87:14: 86| enableParallelBuilding = true; 87| inherit buildCommand name; | ^ 88| passAsFile = [ "buildCommand" ] (stack trace truncated; use '--show-trace' to show the full trace) error: getting status of '/nix/store/xl229jfp80rpw7jymzaf87wsh4wylg28-source': No such file or directory ``` If you have a problem with a specific package or NixOS, you probably want to file an issue at https://github.com/NixOS/nixpkgs/issues. **Steps To Reproduce** I don't know how to reproduce this. Here's what I did before it occurs: 1. Run `nix-store --gc` because of disk space outage. 2. Wait for about a minute to tens of GiBs of disk space 3. Open another terminal emulator 4. Run `cd .config/nixos`, the directory of the Home Manager Configuration flake. 5. Run `home-manager --flake . switch` 6. See the evaluation proceeds, while complaining `warning: error: SQLite database '/nix/var/nix/db/db.sqlite' is busy` twice 7. See the evaluation finishes and the build starts. Packages are fetched from the binary cache. 8. See something gets build. 9. See the error complaining about the missing store path. **Expected behavior** In the multi-user Nix installation, the users expect Nix to prevent race condition when `nix-store --gc` and `nix-build` is run by different processes or even different users. This should not be at the expense of a full blockage of `nix-build` during the `nix-store --gc` execution. **`nix-env --version` output** nix-env (Nix) 2.15.2 **Additional context** `nix-info -m` output: - system: `"x86_64-linux"` - host os: `Linux 6.1.55, NixOS, 23.05 (Stoat), 23.05.20231007.5a237ae` - multi-user?: `yes` - sandbox: `yes` - version: `nix-env (Nix) 2.15.2` - nixpkgs: `/nix/store/hwqz0b3d0wcyjvb4fda1wf8lhj4vaa4m-source` Add any other context about the problem here. **Priorities** Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
lix-bot added the
bug
imported
labels 2024-03-16 06:44:51 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#90
No description provided.