Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix maybeGC trigger condition #2010

Merged
merged 2 commits into from
Dec 1, 2015
Merged

Fix maybeGC trigger condition #2010

merged 2 commits into from
Dec 1, 2015

Conversation

rht
Copy link
Contributor

@rht rht commented Nov 27, 2015

Caveat: if pin size > watermark or storagemax, the gc will trigger but won't clean the pinned files.

cc: @lgierth

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
License: MIT
Signed-off-by: rht <rhtbot@gmail.com>
@ghost
Copy link

ghost commented Nov 27, 2015

I'm still not sure about the StorageMax check. It's good that it tries to prevent effectless GC runs, but the calculation seems off to me.

// GetStorageUsage computes the storage space taken by the repo in bytes
func (r *FSRepo) GetStorageUsage() (uint64, error) {
    storage, err := gc.Repo.GetStorageUsage()
        // ...
    if storage+offset > gc.StorageMax {
        err := ErrMaxStorageExceeded
        log.Error(err)
        return err
    }

The check seems to assume that this is the space taken by all pinned objects, and that it can't possibly remove enough blocks to get back below watermark. Although it doesn't actually know how much space it can free, since GetStorageUsage() includes both pinned (not collectable) and non-pinned (collectable) blocks.

The check would have to subtract the size of all pinned blocks, wdyt?

@daviddias daviddias mentioned this pull request Nov 27, 2015
42 tasks
@ghost
Copy link

ghost commented Nov 27, 2015

I think it would also be okay to just leave the check out for now, and get smarter about GC later, incrementally.

@rht
Copy link
Contributor Author

rht commented Nov 27, 2015

The check seems to assume that this is the space taken by all pinned objects, and that it can't possibly remove enough blocks to get back below watermark.

Yes currently it is agnostic to the pin-state of the hashes.

I chose not to isolate the pinned blocks because ipfs repo gc and the repo storage are agnostic to pin state. But if you think it is more natural/manageable to do so, I can implement it.

(Also, I did propose for constraining the number of objects stored (unitless) instead of the space they occupy--faster to compute, but I'm not sure if it is harder to put the constraint)

@whyrusleeping
Copy link
Member

so it looks to me like if the GC fails once, the periodic routine exits. This seems wrong to me. core/corerepo/gc.go:157

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
License: MIT
Signed-off-by: rht <rhtbot@gmail.com>
@rht
Copy link
Contributor Author

rht commented Nov 28, 2015

Fixed.

@ghost
Copy link

ghost commented Nov 28, 2015

@rht still not sure we're understanding each other ;)

pasting a few lines from another chat:

right now auto gc is effectively useless if​ the repo is already bigger than StorageMax
the check in L177 is a little optimization that tries to prevent useless GC runs -- imagine the sum of all pinned blocks being above the watermark -- it'd just try and try to collect without effect
​> what it actually looks at though is size of the whole repo, not just pinned items

... so in my case (GetStorageUsage() = 27G, StorageMax = 20G) it refuses to run GC thinking it can't collect anything, while it can actually collect a lot.


I think the check should either be deactivated/removed, or calculate the storage usage of pinned blocks as the base

@rht
Copy link
Contributor Author

rht commented Nov 28, 2015

The point of this PR is to make GC run even when storage exceeds StorageMax.

@rht
Copy link
Contributor Author

rht commented Nov 28, 2015

The check is cheaper than running the gc itself, and should stay. But sure I will implement the isolating the pin from the gc check, this removes false positive errs.

@ghost
Copy link

ghost commented Nov 28, 2015

Hehe you're right, sorry -- yesterday this patch didn't make a lot of sense to me, somehow, but at least it does now, lol.

I'll give it a test on venus.i.ipfs.io right now.

@ghost
Copy link

ghost commented Nov 28, 2015

It works fine, thank you 👍

@rht
Copy link
Contributor Author

rht commented Nov 28, 2015

While you're at it I wonder if #1924 is still an issue? Though the mem fix is only in dev0.4.0.

@whyrusleeping
Copy link
Member

This LGTM.

@whyrusleeping whyrusleeping removed the status/in-progress In progress label Nov 28, 2015
@ghost ghost mentioned this pull request Nov 29, 2015
log.Warningf("post-GC: Watermark still exceeded")
if newStorage > gc.StorageMax {
err := ErrMaxStorageExceeded
log.Error(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(yes should have been removed)

@jbenet
Copy link
Member

jbenet commented Dec 1, 2015

this LGTM -- solid work @rht @lgierth @whyrusleeping

I'll merge now to keep this moving, can remove the log in another PR

jbenet added a commit that referenced this pull request Dec 1, 2015

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
Fix maybeGC trigger condition
@jbenet jbenet merged commit 34efa3b into master Dec 1, 2015
@jbenet jbenet deleted the hotfix/auto-gc branch December 1, 2015 15:26
@jbenet jbenet mentioned this pull request Dec 7, 2015
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants