Fix/GC: Do not recursively descend all internal pins

InternalPins() is a pinset composed by:

- Recursive pins CIDs
- Direct pins CIDs
- The empty node CID
- A root CID pointing to all above (and any of the subbuckets that may have been created)

It is only set during Flush/Load operations for the pinner.

Thus recursively exploring internal pins in order to decide which CIDs are safe
from GC only re-explores the recursive DAGs and should not be necessary.

Mind that, previously, the CidSet will correctly prune any already explored branches so
it did not have pernicious effects. But now it does.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
This commit is contained in:
Hector Sanjuan 2018-06-21 16:01:58 +02:00
parent 45e9a4c922
commit 9abb9923af

View File

@ -169,7 +169,6 @@ func DescendantsMaxDepth(ctx context.Context, getLinks dag.GetLinks, set *cid.Se
for _, recPin := range roots {
set.Add(recPin.Cid)
// EnumerateChildren recursively walks the dag and adds the keys to the given set
err := dag.EnumerateChildrenMaxDepth(
ctx,
@ -231,10 +230,10 @@ func ColoredSet(ctx context.Context, pn pin.Pinner, ng ipld.NodeGetter, bestEffo
gcs.Add(k)
}
err = Descendants(ctx, getLinks, gcs, pn.InternalPins())
if err != nil {
errors = true
output <- Result{Error: err}
// Internal pins are direct + recursive + empty + root cid
// so we can treat them as direct.
for _, k := range pn.InternalPins() {
gcs.Add(k)
}
if errors {