* Release output locks as soon as possible, not when the destructor of

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.
This commit is contained in:
Eelco Dolstra 2009-02-16 09:24:20 +00:00
parent 2ef579d1aa
commit 824b154ce8
3 changed files with 14 additions and 0 deletions

View File

@ -1023,6 +1023,8 @@ void DerivationGoal::tryToBuild()
} catch (BuildError & e) {
printMsg(lvlError, e.msg());
outputLocks.unlock();
buildUser.release();
if (printBuildTrace) {
if (usingBuildHook)
printMsg(lvlError, format("@ hook-failed %1% %2% %3% %4%")
@ -1130,6 +1132,8 @@ void DerivationGoal::buildDone()
} catch (BuildError & e) {
printMsg(lvlError, e.msg());
outputLocks.unlock();
buildUser.release();
if (printBuildTrace) {
/* When using a build hook, the hook will return a
remote build failure using exit code 100. Anything
@ -2068,6 +2072,7 @@ void DerivationGoal::computeClosure()
create new lock files with the same names as the old (unlinked)
lock files. */
outputLocks.setDeletion(true);
outputLocks.unlock();
}

View File

@ -203,6 +203,12 @@ void PathLocks::lockPaths(const PathSet & _paths, const string & waitMsg)
PathLocks::~PathLocks()
{
unlock();
}
void PathLocks::unlock()
{
for (list<FDPair>::iterator i = fds.begin(); i != fds.end(); i++) {
if (deletePaths) deleteLockFilePreClose(i->second, i->first);
@ -216,6 +222,8 @@ PathLocks::~PathLocks()
debug(format("lock released on `%1%'") % i->second);
}
fds.clear();
}

View File

@ -36,6 +36,7 @@ public:
void lockPaths(const PathSet & _paths,
const string & waitMsg = "");
~PathLocks();
void unlock();
void setDeletion(bool deletePaths);
};