aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/pathlocks.hh
AgeCommit message (Collapse)Author
2021-10-13Non-blocking garbage collectorEelco Dolstra
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.
2019-08-02Use BSD instead of POSIX file locksEelco Dolstra
POSIX file locks are essentially incompatible with multithreading. BSD locks have much saner semantics. We need this now that there can be multiple concurrent LocalStore::buildPaths() invocations.
2018-02-12Fix 'deadlock: trying to re-acquire self-held lock'Eelco Dolstra
This was caused by derivations with 'allowSubstitutes = false'. Such derivations will be built locally. However, if there is another SubstitionGoal that has the output of the first derivation in its closure, then the path will be simultaneously built and substituted. There was a check to catch this situation (via pathIsLockedByMe()), but it no longer worked reliably because substitutions are now done in another thread. (Thus the comment 'It can't happen between here and the lockPaths() call below because we're not allowing multi-threading' was no longer valid.) The fix is to handle the path already being locked in both SubstitutionGoal and DerivationGoal.
2017-01-26openLockFile: Return an AutoCloseFDEelco Dolstra
2016-06-03Support sandbox builds by non-root usersEelco Dolstra
This allows an unprivileged user to perform builds on a diverted store (i.e. where the physical store location differs from the logical location). Example: $ NIX_LOG_DIR=/tmp/log NIX_REMOTE="local?real=/tmp/store&state=/tmp/var" nix-build -E \ 'with import <nixpkgs> {}; runCommand "foo" { buildInputs = [procps nettools]; } "id; ps; ifconfig; echo $out > $out"' will do a build in the Nix store physically in /tmp/store but logically in /nix/store (and thus using substituters for the latter).
2012-07-18Use "#pragma once" to prevent repeated header file inclusionEelco Dolstra
2010-02-03* Revert r19797, and use a simpler solution: just don't monitor buildEelco Dolstra
hooks for silence. It's unnecessary because the remote nix-store command is already monitoring the real build.
2010-02-03* While waiting for a lock, print a sign of life every 5 minutes.Eelco Dolstra
This prevents remote builders from being killed by the `max-silent-time' inactivity monitor while they are waiting for a long garbage collection to finish. This happens fairly often in the Hydra build farm.
2010-02-02* Remove most Cygwin-specific code. Cygwin 1.7 implements advisoryEelco Dolstra
POSIX locks, and simulates Unix-style file deletion semantics sufficiently. Note that this means that Nix won't work on Cygwin 1.5 anymore.
2009-03-23* No longer block while waiting for a lock on a store path. InsteadEelco Dolstra
poll for it (i.e. if we can't acquire the lock, then let the main select() loop wait for at most a few seconds and then try again). This improves parallelism: if two nix-store processes are both trying to build a path at the same time, the second one shouldn't block; it should first see if it can build other goals. Also, it prevents the deadlocks that have been occuring in Hydra lately, where a process waits for a lock held by another process that's waiting for a lock held by the first. The downside is that polling isn't really elegant, but POSIX doesn't provide a way to wait for locks in a select() loop. The only solution would be to spawn a thread for each lock to do a blocking fcntl() and then signal the main thread, but that would require pthreads.
2009-02-16* Release output locks as soon as possible, not when the destructor ofEelco Dolstra
the DerivationGoal runs. Otherwise, if a goal is a top-level goal, then the lock won't be released until nix-store finishes. With --keep-going and lots of top-level goals, it's possible to run out of file descriptors (this happened sometimes in the build farm for Nixpkgs). Also, for failed derivation, it won't be possible to build it again until the lock is released. * Idem for locks on build users: these weren't released in a timely manner for failed top-level derivation goals. So if there were more than (say) 10 such failed builds, you would get an error about having run out of build users.
2008-05-21* GCC 4.3.0 (Fedora 9) compatibility fixes. Reported by Gour andEelco Dolstra
Armijn Hemel.
2007-08-28* Fix a race condition with parallel builds where multipleEelco Dolstra
fixed-output derivations or substitutions try to build the same store path at the same time. Locking generally catches this, but not between multiple goals in the same process. This happened especially often (actually, only) in the build farm with fetchurl downloads of the same file being executed on multiple machines and then copied back to the main machine where they would clobber each other (NIXBF-13). Solution: if a goal notices that the output path is already locked, then go to sleep until another goal finishes (hopefully the one locking the path) and try again.
2006-09-04* Use a proper namespace.Eelco Dolstra
* Optimise header file usage a bit. * Compile the parser as C++.
2006-06-20* Concurrent GC on Cygwin.Eelco Dolstra
2006-06-15* In `nix-env -i|-u|-e', lock the profile to prevent races betweenEelco Dolstra
concurrent nix-env operations on the same profile. Fixes NIX-7.
2005-01-27* Make lock removal safe by signalling to blocked processes that theEelco Dolstra
lock they are waiting on has become stale (we do this by writing a meaningless token to the unlinked file).
2004-05-11* True parallel builds. Nix can now run as many build jobs inEelco Dolstra
parallel as possible (similar to GNU Make's `-j' switch). This is useful on SMP systems, but it is especially useful for doing builds on multiple machines. The idea is that a large derivation is initiated on one master machine, which then distributes sub-derivations to any number of slave machines. This should not happen synchronously or in lock-step, so the master must be capable of dealing with multiple parallel build jobs. We now have the infrastructure to support this. TODO: substitutes are currently broken.
2003-11-21* Remove lock files after building. Eelco Dolstra
2003-11-18* libnix -> libstore.Eelco Dolstra