Merge "fix(gc): log sudden "path in use" exceptions and recover during GC gracefully" into main

This commit is contained in:
jade
2025-01-23 06:03:33 +00:00
committed by Gerrit Code Review
+10 -3
View File
@@ -746,9 +746,16 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
for (auto & path : topoSortPaths(visited)) {
if (!dead.insert(path).second) continue;
if (shouldDelete) {
invalidatePathChecked(path);
deleteFromStore(path.to_string());
referrersCache.erase(path);
try {
invalidatePathChecked(path);
deleteFromStore(path.to_string());
referrersCache.erase(path);
} catch (PathInUse &) {
// References to upstream "bugs":
// https://github.com/NixOS/nix/issues/11923
// https://git.lix.systems/lix-project/lix/issues/621
printInfo("Skipping deletion of path '%1%' because it is now in use, preventing its removal.", printStorePath(path));
}
}
}
};