-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 inability to pin two things at once #5512
Conversation
55338e6
to
4613e53
Compare
4613e53
to
df09116
Compare
My concern with this is that we're requiring that the caller hold this lock and, if they aren't holding it, we can end up in a bad pin state (where we think something has been pinned but it hasn't). This will cause GC to hard-fail (it will simply refuse to run). We actually have some code that will call this without holding that lock. I can pretty much guarantee that we won't run into issues but I'd feel more comfortable with a completely correct fix. At the moment, I can't think of any simple and correct fixes that don't involve giving the |
Note: There may actually be other solutions and I'd love to have alternatives. One would be to just fix all calls to |
@lus0p let's let @michaelavila work on this one for now. |
I'm looking into your suggestions now, but I want to run something by you. This PR solves a very specific problem, but as you noted there is another problem that we would like to solve to make the overall solution more correct. Are you amenable to tackling these two problems separately? One thing we can do is get this solution merged (once it's ready) and create an issue to solve the other problem. I see a few benefits:
Ultimately, if this solution (i.e. the code) I'm proposing is flawed in a serious way then I'd recommend not proceeding. But if the problem already exists today (which I believe it does), then I think risk is low. Let me know what you think. |
My issue is that this patch technically introduces a rather nasty bug (albeit one that probably won't come up in practice). We have code that calls A simple alternative is to just fetch everything ahead of time. That is, have the
The downside is that we'll have to traverse the dag twice (once under a lock). On the other hand, this is what |
Basically, I don't want to go straight for the correct fix (get rid of the gclock and instead introduce temporary runtime "pins"). However, I also don't want to introduce a bug (even it it's a rare edge case). |
@Stebalien makes sense, I didn't realize I was introducing something that wasn't already there. I also don't want to introduce a new bug. I'll keep cracking at this after dealing with the sharded ls PR. Thanks for the quick response. |
@Stebalien I've been working through your feedback and trying to understand the problem I may have introduced, but am having trouble. It seems like the issue you're alluding to existed before this change. Can you explain in more detail what issue was introduced by this change? My apologies, I'd like to figure this out without bugging you, but after digging into it both myself and with a pair I am still not sure. Thank you. |
Actually... I think I was wrong. Thanks for asking me to actually think through this. Basically, I figured that holding the pin lock would prevent GC. This is correct. However, we can still have the following sequence of events:
Oops? Yep, we already have that bug. New |
@magik6k could you double-check the logic? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we aren't worried about the case when GC lock is not held, LGTM.
Yeah, turns out taking this lock doesn't actually help. If the GC lock isn't held, bad things can still happen. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I've also looked at all invocations of this method, it seems like all places where GC can happen (so after initialization), do hold n.Blockstore.PinLock()
(unless GC can be triggered while the node is still starting)
Thanks everyone. Before I merge this, I want to resolve the codecov issue which was introduced when I added that check in after re-locking. I'll add a note when that's done. |
License: MIT Signed-off-by: Michael Avila <[email protected]>
License: MIT Signed-off-by: Michael Avila <[email protected]>
7ed1a53
df09116
to
7ed1a53
Compare
(rebased to get github to stop complaining) Let's add tests in a different PR (tests would be much appreciated). It's not an issue with your code, just our test coverage in general. |
@Stebalien ok, are you saying I should just merge this now then? |
Yeah... I'm just trying to get jenkins to pass. |
🎉 |
Goals
Fix #5376 by allowing content to be fetched concurrently when pinning multiple hashes.
Implementation
Simply release the pinner lock when fetching content and re-lock it immediately afterwards.
For Discussion
GCLocker
, but it appears that gc locking is managed here: https://github.com/ipfs/go-ipfs/blob/def80817224835a4965849bd3ac1a1a8da458601/core/commands/pin.go#L71 Which, I think, can be left alone for now.