mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 02:24:21 -05:00
iowait and memory consumption are skyrocketing regularly #4453
Closed
opened 2025-11-02 05:51:17 -06:00 by GiteaMirror
·
40 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1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4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#4453
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @schmittlauch on GitHub (Dec 6, 2019).
[x]):Description
As written earlier in the Discourse forum, it regularly happens that gitea makes my server's iowait and memory consumption skyrocket, causing issues for all other services running within the same VM. Usually only killing the whole gitea service makes the server recover.
While I couldn't find any direct cause by parsing the logs or the PPROF data, I just discovered in the admin web interface (tab Monitoring) that the GetDiffRange operation seems to be responsible. It seems to get stuck at a single repo of just 138MiB size, clogging IO and making gitea consume more and more memory.
iotopshows that gitea creates a lot of I/O, although I'm not sure whether swapping operations are allocated to the process causing them as well.After this issue first occured, I limited the gitea systemd service to 600MiB and gitea is currently using all of it. But apparently this limit isn't working as the memory+swap usage increased by more than 3GiB during the GetDiffRange operation.
What does this GetDiffRange operation do? I wasn't able to find information on that.
Luckily I was able to allocate an additional 1GiB of memory to my VM, giving me the chance to let the operation run. So far it's running for more than 30 minutes though.
Any ideas about that operation, why it's getting stuck or any additional debug information I could provide?
@schmittlauch commented on GitHub (Dec 6, 2019):
After ~45min the GetDiffRange operation vanished from the Monitoring web UI, but both memory consumption and IOwait remain equally high. I see myself forced to kill gitea after additional 15 minutes.
@schmittlauch commented on GitHub (Dec 6, 2019):
Killing the gitea service immediately freed up 4.5GiB of memory.
@lunny commented on GitHub (Dec 8, 2019):
There is a bug about
OpenRepositoryhas been fixed on v1.9.6 or v1.10.0(1?). Could you try v1.10.1?@schmittlauch commented on GitHub (Dec 8, 2019):
will do
@zeripath commented on GitHub (Dec 9, 2019):
I think it's unlikely to be fixed by that - the architecture of GetDiffRange keeps the whole diff in memory. (Probably multiple copies of it too.) If you have a huge diff you're going to break Gitea.
@typeless commented on GitHub (Dec 12, 2019):
References:
https://github.blog/2016-12-06-how-we-made-diff-pages-3x-faster/
https://github.com/go-gitea/gitea/blob/master/services/pull/merge.go#L504-L545
@lunny commented on GitHub (Dec 12, 2019):
We can also cache the diff sections to cache server or files.
@schmittlauch commented on GitHub (Dec 13, 2019):
The issue is still happening regularly even with v1.10.1, but I haven't always seen the "GetDiffRange" operation showing up on the Monitoring page. So GetDiffRange isn't necessarily the cause of this issue.
The gitea logs only show a huge amount of mysql queries and I wasn't able to get anything from the PROF data (I'm not a go developer).
If anyone thinks they can get relevant information from there, I'm willing to pass you the logs and prof data.
@lunny commented on GitHub (Dec 14, 2019):
So that maybe some cron tasks.
@zeripath commented on GitHub (Dec 14, 2019):
Hmm excessive Perm checks are a possible cause - see the comments on #8540?
There's another possible issue - testPatch was previously reading the whole patch in to memory. That should stop now.
@schmittlauch commented on GitHub (Dec 14, 2019):
Judging from the (non?)periodicty-time the issue appears, is at least none of the tasks with a periodicty of 10min or 24h listed in the monitoring tab.
I don't have any repos with an excessively large number of owners, which seems to be the precondition for this issue.
Under which circumstances does
testPatchget triggered?@zeripath commented on GitHub (Dec 14, 2019):
Changes to PRs would cause that
@zeripath commented on GitHub (Dec 14, 2019):
Do you have repo indexer on? Maybe that could be a cause?
@schmittlauch commented on GitHub (Dec 16, 2019):
I didn't modify any PRs in the meantime and do not have the indexer enabled (if it's disabled by default). git-lfs is enabled though.
Nevertheless after a while my gitea uses 2GiB of memory:
Server Uptime
9 hours, 34 minutes, 53 seconds
Current Goroutines
29
Current Memory Usage
44MB
Total Memory Allocated
17GB
Memory Obtained
2.8GB
Pointer Lookup Times
0
Memory Allocations
103340464
Memory Frees
102837346
Current Heap Usage
44MB
Heap Memory Obtained
2.7GB
Heap Memory Idle
2.6GB
Heap Memory In Use
52MB
Heap Memory Released
2.6GB
Heap Objects
503118
Bootstrap Stack Usage
928KB
Stack Memory Obtained
928KB
MSpan Structures Usage
678KB
MSpan Structures Obtained
8.2MB
MCache Structures Usage
5.1KB
MCache Structures Obtained
16KB
Profiling Bucket Hash Table Obtained
2.3MB
GC Metadata Obtained
97MB
Other System Allocation Obtained
1.6MB
Next GC Recycle
86MB
Since Last GC Time
19.3s
Total GC Pause
0.2s
Last GC Pause
0.000s
GC Times
382
(taken from the admin dashboard)
@lunny commented on GitHub (Dec 16, 2019):
I think in fact
is the memory what go used.
@schmittlauch commented on GitHub (Dec 16, 2019):
@lunny No, according to htop
gitea webuses 54.5% of my 3.86 GiB of RAM.freegives a difference of 2206128 Bytes (used) after stopping the gitea service, that's 2.1 GiB.@schmittlauch commented on GitHub (Dec 16, 2019):
If the PROF files may be useful, I can provide you with those. I was too dumb to analyse them myself.
@schmittlauch commented on GitHub (Jan 6, 2020):
Any ideas on what I can do to figure out what the memory is even used for?
Maybe taking the memory dump of the gitea process(es) via /proc/ and somehow analysing it?
@zeripath commented on GitHub (Jan 6, 2020):
OK so on master I recently made a change that means that PR patches are not stored in memory - that could have been to blame.
The other places that are currently poorly written are diff and blame as these both read the whole thing into memory.
I've never used the prof output so I'd be starting from scratch with that.
@schmittlauch commented on GitHub (Jan 7, 2020):
I really doubt that, as my repos have nearly no PRs.
Once I find the time I'll try disabling individual repos, maybe I can pin down the issue to a single repo.
@schmittlauch commented on GitHub (Feb 7, 2020):
I'd like to disable individual repos to see whether a single certain repo causes this issue.
Is there a convenient way to do this or do I need to delete the repos individually and later re-add them and restore issues + PRs from backup?
@guillep2k commented on GitHub (Feb 7, 2020):
If you're using Linux, maybe you can try the following command to check what processes are using what repos at a given time:
The above command requires using root credentials.
With Windows you'd need sysinternals' process monitor (MS official).
@schmittlauch commented on GitHub (Mar 19, 2020):
I deleted all repositories but one, now the memory issue vanished.
I am going to try to pin down which (single?) repository is causing the issue.
Unfortunately I am inly able to do this on my production instance. So if there is a more convenient way of disabling and restoring repos than
gitea dumpand restoring all repos afterwards, I'd be glad to hear them.@stale[bot] commented on GitHub (May 18, 2020):
This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
@schmittlauch commented on GitHub (May 18, 2020):
This is still an issue, but unfortunately I haven't been able to pin it down further.
The current memory stats of my gitea 1.11.5 instance:
According to htop, the
gitea webprocess currently uses 2194MiB of memory (RES) and has 8190MiB allocated virtually (VIRT).From the admin dashboard:
Server Uptime
3 days, 5 hours, 57 minutes, 4 seconds
Current Goroutines
72
Current Memory Usage
85MB
Total Memory Allocated
275GB
Memory Obtained
5.9GB
Pointer Lookup Times
0
Memory Allocations
914241923
Memory Frees
913578269
Current Heap Usage
85MB
Heap Memory Obtained
5.7GB
Heap Memory Idle
5.6GB
Heap Memory In Use
99MB
Heap Memory Released
5.5GB
Heap Objects
663654
Bootstrap Stack Usage
1.4MB
Stack Memory Obtained
1.4MB
MSpan Structures Usage
882KB
MSpan Structures Obtained
38MB
MCache Structures Usage
5.1KB
MCache Structures Obtained
16KB
Profiling Bucket Hash Table Obtained
6.6MB
GC Metadata Obtained
215MB
Other System Allocation Obtained
4.6MB
Next GC Recycle
129MB
Since Last GC Time
7.3s
Total GC Pause
6.2s
Last GC Pause
0.000s
GC Times
3145
@stale[bot] commented on GitHub (Jul 18, 2020):
This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
@eikendev commented on GitHub (Jul 23, 2020):
I think I'm experiencing the same issue. I'm using the Docker image with version
1.13.0+dev-329-gd25f44285.I see that one of my repositories has some huge diffs, so I'll try remove the repository from Gitea and report back if that changes anything.
Down below you see how I get weird spikes in memory usage, caused by Gitea. When the Docker container is stopped, memory recovers to somewhere between 30% and 35%.
Also note that on this instance, LFS is disabled.
Edit: After about two days the issue has not come back. My conclusion is that repositories with huge diffs are a no-no on Gitea for now.
@schmittlauch commented on GitHub (Jul 28, 2020):
@eikendev What do you categorise as huge diffs and how can I check whether one of my repos falls into that category?
Gitea is still acting up, eating all my memory and swap:
It also leaves broken git processes behind.
There are 13
gitea webthreads running which, as I read somewhere, isn't supposed to be the case, right?Metrics from the admin dashboard, the memory + swap usage seems to be pretty equal with Memory Obtained:
@schmittlauch commented on GitHub (Jul 28, 2020):
For comparison, after a restart, Memory Obtained is back at 137MiB:
gitea-1.11.8
@zeripath commented on GitHub (Jul 28, 2020):
Hmm... I've got a few ideas here:
Our blame code used to potentially fail to close the git process - that should be fixed on 1.13 and I think it was backported to 1.12. So that would be a cause for defunct gits on 1.11.8.
Another cause of the defunct git processes could be git gc.
When we run git gc git will attempt to repack things. This process can take a lot of memory and would cause a regular spike.
It's potentially worth running git gc on the command line for the in turn repositories. It may be that we have incorrect options or you need to set the pack configuration options in your global git configuration. If these git gc processes die then they can go defunct - but you should have some information on the processes page when this is happening.
@schmittlauch commented on GitHub (Jul 28, 2020):
@zeripath
I've already tried to bisect the repos to find the responsible one, but the process for doing so is quite bothersome:
Due to the lack of repo-level import/export, I always had to backup the whole gitea instance, remove some repos, wait to see the result, and then nuke the whole instance before restoring the whole backup.
Is there any better way?
@eikendev commented on GitHub (Jul 28, 2020):
It was a repository where a file of over 100MB was added, something that actually belongs into lfs.
I guess my specific case can be detected by looking for large files inside the repository. About the general case, maybe
git log --stathelps.@zeripath commented on GitHub (Jul 28, 2020):
@eikendev that's bad - do you know if it was when the file was pushed or when someone looked at the diff page?
@zeripath commented on GitHub (Jul 28, 2020):
oo interesting I just pushed a file with no newlines and memory shot up.
@eikendev commented on GitHub (Jul 28, 2020):
In the graph I posted earlier I have neither pushed anything nor loaded any huge diff. I looked at the repo at some points, but not the diffs. When memory is freed in the graph, this would indicate I manually restarted the server.
To me this seems more like a product of a scheduled task.
I'm not sure right now if my issue and @schmittlauch's are related.
@lafriks commented on GitHub (Jul 28, 2020):
Do you see what is exact git command (with arguments) that is left dangling?
@schmittlauch commented on GitHub (Jul 28, 2020):
@lafriks Currently there is no dangling git command after having restarted gitea.
I'll keep that in mind for the future, but the growth of memory consumption happens independent of dangling git processes being present or not. Right now my 3.5GiB memory are nearly full, the growth will continue into swap the next day.
@zeripath commented on GitHub (Feb 14, 2021):
OK I think this is going to be related to go-git related issues.
I think therefore I'm going to pull the confirmed from this tag to see if 1.14 still has this issue.
@zeripath commented on GitHub (Dec 15, 2021):
I think I might have discovered the underlying issue here - if git cat-file is called on a broken git repository it will hang until stdin is closed instead of fatalling immediately. I think therefore #17991 will fix this.
@schmittlauch commented on GitHub (Dec 15, 2021):
This issue might even be resolved already, but I cannot say for sure as I moved my installation to a new installation, cleaned up some old repos, and thus might have removed such a broken repo coincidentally.
So I suggest to indeed close this once #17991 gets merged, unless some new instance of these symptoms here comes up.