-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add finalizers to ensure that repos are closed and blobreaders are closed #19495
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
Conversation
…osed It may be prudent to add runtime finalizers to the git.Repository and git.blobReader objects to absolutely ensure that these are both properly cancelled, cleaned and closed out. This commit is an extract from go-gitea#19448 Signed-off-by: Andrew Thornton <[email protected]>
There could be an error log to tell developers that the resource is not closed correctly. Otherwise this patch only hide problems. |
Signed-off-by: Andrew Thornton <[email protected]>
I don't think it's a good idea to do that. We should find the real problem. |
Signed-off-by: Andrew Thornton <[email protected]>
I have no information to suggest that we have any leaks, nor that we should rely on finalizers to deal with them. However, if we do have leaks - it is infinitely better for a finalizer to take care of them than to have a leak there. But I do take your point that this could hide a leak - which isn't great so to that end I have pushed a commit that would add some warnings IF the finalizer were to be relied on. |
Signed-off-by: Andrew Thornton <[email protected]>
Signed-off-by: Andrew Thornton <[email protected]>
I just wonder if this cost us performance? |
…osed (#19495) (#19496) It may be prudent to add runtime finalizers to the git.Repository and git.blobReader objects to absolutely ensure that these are both properly cancelled, cleaned and closed out. This commit is a backport of an extract from #19448 Signed-off-by: Andrew Thornton <[email protected]>
So there will probably be a small perf hit:
Now... the addition of locks is going to be helpful because if this gets merged we can try not opening the batch and batchcheck readers until they're actually first called for. |
We should remove the finalizer on the object on the |
Small note: since when are backports merged before the normal PR are merged? |
…n reopen Signed-off-by: Andrew Thornton <[email protected]>
OK @Gusted I've setFinalizer(nil) for these structs on close. (except the go-git variant as I am fairly sure that the storage can be reopened even after close. |
The backport version #19496 introduced a major memory leak. I am not sure if the recent commits added this one would fix it. |
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.
FYI, I added a gitea/modules/context/context.go Lines 78 to 86 in cd99540
|
It may be prudent to add runtime finalizers to the git.Repository and
git.blobReader objects to absolutely ensure that these are both properly
cancelled, cleaned and closed out.
This commit is an extract from #19448
Signed-off-by: Andrew Thornton [email protected]