-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copying lots of paths fails with "too many root sets" #7359
Comments
I ran into this issue also. Works in Nix 2.9.1 and 2.10.3 but not in 2.11.1 and 2.12.0. |
This is the callstack of the error:
Seems to have been introduced here: #6612 |
@thufschmitt It seems that doing the work of draining all paths here inside the same lambda is a bit too much for the garbage collector. Not sure what the correct fix is though, batching? |
I'm not sure what causes it to crash since that should be properly streaming 🤔 @edolstra since you're the original author of that “low-latency ssh copying”, any idea what might go wrong? I must confess I'm not entirely clear on how it works |
This happens when I'm using deploy-rs (it copies store via ssh-ng://) |
This is something I'm hitting on a nearly daily basis as nixos-unstable moves. I have a number of systems that don't really get cache hits, causing large rebuilds and thus numerous derivations to copy. Unfortunately it's causing enough noise that I'm getting close to writing another nix wrapper that looks for the crash string and just retries the copy, but that's not ideal. (Thanks to those investigating / looking at fixes!) |
Especially annoying when dealing with slow internet, as it doesn't allow to build on remote. |
Running into this with nixos-anywhere using
|
Since the OP and other commenters only reported getting the error when using the Background: |
|
I ran into this on Nix 2.23.1 today. Copying from a file export into the local store, so no network involved at all:
The output was:
Ignoring the fact it's reporting copying much more data than it expected (that's tracked in #9088), the output is concatenated with the error message. |
There's no explanation on why in the Gerrit, but I noticed that the Lix project have refactored this area to remove the |
@a-h where you able to do the same operation with lix? |
I haven't been able to reproduce the issue on my laptops, maybe because they have a lot more RAM (32GB and 64GB respectively), than the server I was using (8GB). I tested out copying my whole store There were around 60k paths to copy, and that copied everything quite well. It could be that the slowness of the copy operation gives the GC time to act. I made a repo to test that creates 100k derivations: https://github.com/a-h/nix-7359 but that worked fine on my 32GB RAM laptop. It could be that it's deeply nested derivations that cause the issue to surface, so a simple map to create derivations might not be enough. |
Thanks for taking time for setting up a reproducer. If it only happens with RAM pressure, a nixos vm should work. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2025-01-08-nix-team-meeting-minutes-207/58523/1 |
I had a look at the issue, although I'm missing a good test case. I wasn't able to reproduce the issue with https://github.com/a-h/nix-7359, although it provides some useful insights. Newer nix versions use more memory than old nix versions because The current implementations of I wrote a patch, which passes data in in chunks through It would be nice if someone can test whether the patch fixes the issue. EDIT: I observe the increased memory usage of current nix versions using the test case, when copying |
This allows RemoteStore::addMultipleToStore() to free the Source objects early (and in particular the associated sinkToSource() buffers). This should fix NixOS#7359. For example, memory consumption of nix copy --derivation --to ssh-ng://localhost?remote-store=/tmp/nix --derivation --no-check-sigs \ /nix/store/4p9xmfgnvclqpii8pxqcwcvl9bxqy2xf-nixos-system-...drv went from 353 MB to 74 MB.
This allows RemoteStore::addMultipleToStore() to free the Source objects early (and in particular the associated sinkToSource() buffers). This should fix #7359. For example, memory consumption of nix copy --derivation --to ssh-ng://localhost?remote-store=/tmp/nix --derivation --no-check-sigs \ /nix/store/4p9xmfgnvclqpii8pxqcwcvl9bxqy2xf-nixos-system-...drv went from 353 MB to 74 MB. (cherry picked from commit cc838e8)
This allows RemoteStore::addMultipleToStore() to free the Source objects early (and in particular the associated sinkToSource() buffers). This should fix #7359. For example, memory consumption of nix copy --derivation --to ssh-ng://localhost?remote-store=/tmp/nix --derivation --no-check-sigs \ /nix/store/4p9xmfgnvclqpii8pxqcwcvl9bxqy2xf-nixos-system-...drv went from 353 MB to 74 MB. (cherry picked from commit cc838e8)
@edolstra Users reported that this issue was worse with slow internet, i.e. the size of allocated buffers increased in this case. Your patch fixes the root cause of the increased memory usage; nevertheless the implementation of |
Describe the bug
Steps To Reproduce
nix copy --to ssh-ng://root@$host ./*.drv
or similarExpected behavior
Successful copy, or useful error message
nix-env --version
outputnix-env (Nix) 2.12.0pre20221116_561440b
The text was updated successfully, but these errors were encountered: