-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Non-blocking garbage collector #5149
Conversation
02fccb3
to
71d2a14
Compare
cc @domenkozar maybe relevant for cachix watch-store? |
Will Nix then consider referrers paths a valid? |
I hope referrers to a path will still prevent deletions! |
Yes, if a path has any refererrs, then deletion will fail. Previously it would recursively delete unreachable referrers (especially dangerous in combination with |
2d68855
to
c8147c1
Compare
7a06d24
to
c63af2f
Compare
The garbage collector no longer blocks other processes from adding/building store paths or adding GC roots. To prevent the collector from deleting store paths just added by another process, processes need to connect to the garbage collector via a Unix domain socket to register new temporary roots.
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
This test broke the assumption that the hash parts of store paths are unique.
(where "referrers" includes the reverse of derivation outputs and derivers). Now we do a full traversal to look if we can reach any root. If not, all paths reached can be deleted.
75115fc
to
35c98a5
Compare
This fixes a bug in the garbage collector where if a path /nix/store/abcd-foo is valid, but we do a isValidPath("/nix/store/abcd-foo.lock") first, then a negative entry for /nix/store/abcd is added to pathInfoCache, so /nix/store/abcd-foo is subsequently considered invalid and deleted.
The client thread can't just delete its own thread object from connections, it has to detach it.
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/tweag-nix-dev-update-20/15727/1 |
b3837b9
to
33d04e8
Compare
} catch (SysError & e) { | ||
/* The garbage collector may have exited, so we need to | ||
restart. */ | ||
if (e.errNo == EPIPE) { | ||
debug("GC socket disconnected"); | ||
state->fdRootsSocket.close(); | ||
goto restart; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing a rethrow for other error codes (#6648).
This makes it possible to run builds when the garbage collector is running. So the message
waiting for the big garbage collector lock...
is a thing of the past.Processes that start while the GC is running inform the GC process by connecting to the latter via a Unix domain socket (
/nix/var/nix/gc-socket/socket
). They write a path to the socket and then read a single-byte response to synchronize. After receiving the response, the GC process knows about the new root and won't delete it.Note:
nix-store --delete <path>
will no longer delete the referrers of<path>
. That was probably not expected behaviour anyway.