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

Timeout http requests to avoid large memory use in some circumstances. #8146

Closed
1 of 4 tasks
cboylan opened this issue Sep 10, 2019 · 5 comments
Closed
1 of 4 tasks

Comments

@cboylan
Copy link
Contributor

cboylan commented Sep 10, 2019

Description

Processing requests on large repos consumes a fair bit of memory (this isn't a gitea issue, that is due to git). Normally this isn't an issue unless we end up processing requests that take a very long time (see gist for examples). When this happens we can pile up very large (in memory) git processes as we handle these requests. If we get enough of them together we can OOM potentially killing gitea.

It seems that it might be advantageous to timeout these requests and return an error to a user after some reasonable amount of time to avoid memory pressure issues. Better to error gracefully than crash.

To this end I've been poking at adding http request timeouts to gitea here: cboylan@d11d4da

I have a few questions about this. Is there a better way to handle this with gitea? Something might already exist? If not will timing out the requests kill the backend git processes? It seems that an exception is raised when data is written to a request that has been timed out and I'm not sure we are going to write until git is done doing what ever it is doing.

Mostly opening this issue to start a conversation and point at some code that might illustrate things a bit (even though it is probably terrible code on my part). Please let me know what you think and whether or not this should be pursued further.

This might also be related to #491

@lafriks
Copy link
Member

lafriks commented Sep 11, 2019

I think we have something for git process exec timeouts already

@lunny
Copy link
Member

lunny commented Sep 12, 2019

Currently all git command line invoke will be managed by process and we also have a monitor on admin UI. And I think it supports timeout setting.

@cboylan
Copy link
Contributor Author

cboylan commented Sep 18, 2019

Thank you for these pointers. It does indeed appear that there is a default git timeout of 60 seconds on all git commands that are executed (certain commands override this default with longer timeouts but nothing longer than 10 minutes).

It appears I will need to look elsewhere for the cause of these multi hour requests. Any suggestions on how one might go about getting further profiling data?

@stale
Copy link

stale bot commented Nov 17, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Nov 17, 2019
@stale
Copy link

stale bot commented Dec 2, 2019

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale stale bot closed this as completed Dec 2, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants