Fix deletion test

Lower layer references are ignored for deleting just in the upper layer.
This commit is contained in:
John Ericson 2023-07-25 17:09:23 -04:00
parent 19c43c5d78
commit 07b34edc44
4 changed files with 30 additions and 1 deletions

View file

@ -741,7 +741,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
auto i = referrersCache.find(*path); auto i = referrersCache.find(*path);
if (i == referrersCache.end()) { if (i == referrersCache.end()) {
StorePathSet referrers; StorePathSet referrers;
queryReferrers(*path, referrers); queryGCReferrers(*path, referrers);
referrersCache.emplace(*path, std::move(referrers)); referrersCache.emplace(*path, std::move(referrers));
i = referrersCache.find(*path); i = referrersCache.find(*path);
} }

View file

@ -138,6 +138,12 @@ void LocalOverlayStore::queryReferrers(const StorePath & path, StorePathSet & re
} }
void LocalOverlayStore::queryGCReferrers(const StorePath & path, StorePathSet & referrers)
{
LocalStore::queryReferrers(path, referrers);
}
StorePathSet LocalOverlayStore::queryValidDerivers(const StorePath & path) StorePathSet LocalOverlayStore::queryValidDerivers(const StorePath & path)
{ {
auto res = LocalStore::queryValidDerivers(path); auto res = LocalStore::queryValidDerivers(path);
@ -188,6 +194,7 @@ void LocalOverlayStore::deleteGCPath(const Path & path, uint64_t & bytesFreed)
} }
} }
void LocalOverlayStore::optimiseStore() void LocalOverlayStore::optimiseStore()
{ {
Activity act(*logger, actOptimiseStore); Activity act(*logger, actOptimiseStore);
@ -216,6 +223,7 @@ Path LocalOverlayStore::toRealPathForHardLink(const StorePath & path)
: Store::toRealPath(path); : Store::toRealPath(path);
} }
static RegisterStoreImplementation<LocalOverlayStore, LocalOverlayStoreConfig> regLocalOverlayStore; static RegisterStoreImplementation<LocalOverlayStore, LocalOverlayStoreConfig> regLocalOverlayStore;
} }

View file

@ -115,7 +115,16 @@ private:
void optimiseStore() override; void optimiseStore() override;
/**
* For lower-store paths, we used the lower store location. This avoids the
* wasteful "copying up" that would otherwise happen.
*/
Path toRealPathForHardLink(const StorePath & storePath) override; Path toRealPathForHardLink(const StorePath & storePath) override;
/**
* Deletion only effects the upper layer, so we ignore lower-layer referrers.
*/
void queryGCReferrers(const StorePath & path, StorePathSet & referrers) override;
}; };
} }

View file

@ -230,6 +230,18 @@ public:
void collectGarbage(const GCOptions & options, GCResults & results) override; void collectGarbage(const GCOptions & options, GCResults & results) override;
/**
* Called by `collectGarbage` to trace in reverse.
*
* Using this rather than `queryReferrers` directly allows us to
* fine-tune which referrers we consider for garbage collection;
* some store implementations take advantage of this.
*/
virtual void queryGCReferrers(const StorePath & path, StorePathSet & referrers)
{
return queryReferrers(path, referrers);
}
/** /**
* Called by `collectGarbage` to recursively delete a path. * Called by `collectGarbage` to recursively delete a path.
* The default implementation simply calls `deletePath`, but it can be * The default implementation simply calls `deletePath`, but it can be