Search code examples
nixnixos

`nix-build` process caught up in locking, never terminating


On NixOS 20.09, I experience the problem when running an obelisk project. E.g. I do ob init and add regex-tdfa to the dependencies of frontend/frontend.cabal.

Then

> nix-build -A exe --no-out-link -vvv

And I get a never ending output of lines similar to this:

building of '/nix/store/njiphyrb4xcnnckclvv0r2ns65yipnkp-mmorph-1.1.3.tar.gz.drv': woken up
building of '/nix/store/nsncr60fii4fwki70bb5ishf1hzq89b5-coreutils-8.31.drv': created
building of '/nix/store/nsncr60fii4fwki70bb5ishf1hzq89b5-coreutils-8.31.drv': woken up
building of '/nix/store/pvq34lb5r34bypfl53hx8kibakzqw7fc-gnused-4.7.drv': created
building of '/nix/store/pvq34lb5r34bypfl53hx8kibakzqw7fc-gnused-4.7.drv': woken up
building of '/nix/store/xr4aygslk3lqdz9wnsq04vpbm4v68vk5-glibc-locales-2.27.drv': created
building of '/nix/store/xr4aygslk3lqdz9wnsq04vpbm4v68vk5-glibc-locales-2.27.drv': woken up
building of '/nix/store/m3dzp25n0g4fwlygdhvak1kk8xz906n9-bash-4.4-p23.drv': init
building of '/nix/store/m3dzp25n0g4fwlygdhvak1kk8xz906n9-bash-4.4-p23.drv': loading derivation
acquiring write lock on '/nix/var/nix/temproots/21932'
downgrading to read lock on '/nix/var/nix/temproots/21932'
building of '/nix/store/m3dzp25n0g4fwlygdhvak1kk8xz906n9-bash-4.4-p23.drv': have derivation
acquiring write lock on '/nix/var/nix/temproots/21932'
downgrading to read lock on '/nix/var/nix/temproots/21932'
acquiring write lock on '/nix/var/nix/temproots/21932'
downgrading to read lock on '/nix/var/nix/temproots/21932'
acquiring write lock on '/nix/var/nix/temproots/21932'
downgrading to read lock on '/nix/var/nix/temproots/21932'
acquiring write lock on '/nix/var/nix/temproots/21932'
downgrading to read lock on '/nix/var/nix/temproots/21932'
acquiring write lock on '/nix/var/nix/temproots/21932'
downgrading to read lock on '/nix/var/nix/temproots/21932'

The process nix-daemon runs with 100% CPU-time. If do sudo nix-build ..., the nix-build process itself runs with 100% CPU-time, never terminating.

Others tried to reproduce and didn't encounter the problem. It might be related to my hardware. See this reddit post with comments.

Further information

  • The problem only occurs with packages in the frontend, i.e. packages that are being compiled by ghcjs. The log output doesn't point to any ghcjs-related problem, though.
  • The package regex-tdfa is not the problem, as I also experience the same problem now, just building the obelisk static files derivation on a more complex project, and with a couple of other packages.
  • I run NixOS 20.09, on an NVME SSD hard drive
  • The ob run command always works, w/o any problem (I can see the functioning result in development mode)
  • I posted the issue in the obelisk project and collected some details about the problem there.
  • I asked about this problem on the NixOS forums, here, and received some hints

Solution

  • I moved to a conventional hard drive and the problem is gone. Of course an actual solution would be nice on how to avoid this issue on an nvme.

    EDIT: The hard-drive was never the problem. The locking issue apparently has been silently solved somewhere around this commit: https://github.com/flyingcircusio/nixpkgs/commit/ac60476ed94fd5424d9f3410c438825f793a8cbb