Store build logs in /nix/var/log/nix/drvs/<XX>
...where <XX> is the first two characters of the derivation. Otherwise /nix/var/log/nix/drvs may become so large that we run into all sorts of weird filesystem limits/inefficiences. For instance, ext3/ext4 filesystems will barf with "ext4_dx_add_entry:1551: Directory index full!" once you hit a few million files.
This commit is contained in:
parent
66fa9e6a4d
commit
536c85ea49
2 changed files with 37 additions and 30 deletions
|
@ -2343,13 +2343,15 @@ Path DerivationGoal::openLogFile()
|
|||
{
|
||||
if (!settings.keepLog) return "";
|
||||
|
||||
string baseName = baseNameOf(drvPath);
|
||||
|
||||
/* Create a log file. */
|
||||
Path dir = (format("%1%/%2%") % settings.nixLogDir % drvsLogDir).str();
|
||||
Path dir = (format("%1%/%2%/%3%/") % settings.nixLogDir % drvsLogDir % string(baseName, 0, 2)).str();
|
||||
createDirs(dir);
|
||||
|
||||
if (settings.compressLog) {
|
||||
|
||||
Path logFileName = (format("%1%/%2%.bz2") % dir % baseNameOf(drvPath)).str();
|
||||
Path logFileName = (format("%1%/%2%.bz2") % dir % string(baseName, 2)).str();
|
||||
AutoCloseFD fd = open(logFileName.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0666);
|
||||
if (fd == -1) throw SysError(format("creating log file `%1%'") % logFileName);
|
||||
closeOnExec(fd);
|
||||
|
@ -2364,7 +2366,7 @@ Path DerivationGoal::openLogFile()
|
|||
return logFileName;
|
||||
|
||||
} else {
|
||||
Path logFileName = (format("%1%/%2%") % dir % baseNameOf(drvPath)).str();
|
||||
Path logFileName = (format("%1%/%2%") % dir % string(baseName, 2)).str();
|
||||
fdLogFile = open(logFileName.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0666);
|
||||
if (fdLogFile == -1) throw SysError(format("creating log file `%1%'") % logFileName);
|
||||
closeOnExec(fdLogFile);
|
||||
|
|
|
@ -460,8 +460,14 @@ static void opReadLog(Strings opFlags, Strings opArgs)
|
|||
foreach (Strings::iterator, i, opArgs) {
|
||||
Path path = useDeriver(followLinksToStorePath(*i));
|
||||
|
||||
Path logPath = (format("%1%/%2%/%3%") %
|
||||
settings.nixLogDir % drvsLogDir % baseNameOf(path)).str();
|
||||
for (int j = 0; j < 2; j++) {
|
||||
if (j == 2) throw Error(format("build log of derivation `%1%' is not available") % path);
|
||||
|
||||
string baseName = baseNameOf(path);
|
||||
Path logPath =
|
||||
j == 0
|
||||
? (format("%1%/%2%/%3%/%4%") % settings.nixLogDir % drvsLogDir % string(baseName, 0, 2) % string(baseName, 2)).str()
|
||||
: (format("%1%/%2%/%3%") % settings.nixLogDir % drvsLogDir % baseName).str();
|
||||
Path logBz2Path = logPath + ".bz2";
|
||||
|
||||
if (pathExists(logPath)) {
|
||||
|
@ -487,8 +493,7 @@ static void opReadLog(Strings opFlags, Strings opArgs)
|
|||
} while (err != BZ_STREAM_END);
|
||||
BZ2_bzReadClose(&err, bz);
|
||||
}
|
||||
|
||||
else throw Error(format("build log of derivation `%1%' is not available") % path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue