Gitea consumes excessive CPU and RAM when mirror tokens expire #14684

Closed
opened 2025-11-02 11:19:56 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @crazyuploader on GitHub (Jun 30, 2025).

Description

My Gitea instance, running in Docker, experienced excessive CPU and RAM usage (CPU maxed out, ~12 GB RAM) when several mirrored repositories failed to sync due to expired GitLab tokens. Instead of failing gracefully, Gitea repeatedly attempted to sync these mirrors, leading to resource exhaustion.

Gitea Version

1.24.2

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

Image

Image

Image

After putting the updated tokens, and restarting the container seems to solve the problem as can be seen below -

Image

Git Version

2.49.0

Operating System

Ubuntu 22.04.5 LTS

How are you running Gitea?

Using official Gitea Docker Images, and running it in a Docker Container.

Database

SQLite

Originally created by @crazyuploader on GitHub (Jun 30, 2025). ### Description My Gitea instance, running in Docker, experienced excessive CPU and RAM usage (CPU maxed out, ~12 GB RAM) when several mirrored repositories failed to sync due to expired GitLab tokens. Instead of failing gracefully, Gitea repeatedly attempted to sync these mirrors, leading to resource exhaustion. ### Gitea Version 1.24.2 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots ![Image](https://github.com/user-attachments/assets/d4f31a12-7d0a-42cc-b7f8-05da4e1b74d0) ![Image](https://github.com/user-attachments/assets/8a12d9b8-8070-4d82-b7ab-86b8fd669de4) ![Image](https://github.com/user-attachments/assets/450cd4c2-d13e-4723-aa59-a15468a6e58d) After putting the updated tokens, and restarting the container seems to solve the problem as can be seen below - ![Image](https://github.com/user-attachments/assets/64376d1c-3883-4a7c-a290-6ecd7294cd0b) ### Git Version 2.49.0 ### Operating System Ubuntu 22.04.5 LTS ### How are you running Gitea? Using official Gitea Docker Images, and running it in a Docker Container. ### Database SQLite
GiteaMirror added the performance/memoryperformance/cputype/bug labels 2025-11-02 11:19:56 -06:00
Author
Owner

@crazyuploader commented on GitHub (Jun 30, 2025):

I can attach goroutine diagnosis zip file, if that helps :)

@crazyuploader commented on GitHub (Jun 30, 2025): I can attach goroutine diagnosis zip file, if that helps :)
Author
Owner

@lunny commented on GitHub (Jun 30, 2025):

Please post the gorountine diagnosis zip file.
And if possible, please enable performance tracing and share the trace files with us for further analysis.

@lunny commented on GitHub (Jun 30, 2025): Please post the gorountine diagnosis zip file. And if possible, please enable performance tracing and share the trace files with us for further analysis.
Author
Owner

@crazyuploader commented on GitHub (Jul 1, 2025):

Please post the gorountine diagnosis zip file. And if possible, please enable performance tracing and share the trace files with us for further analysis.

The goroutine diagnosis file is given below, it's when I was checking site administration settings in Gitea, when I stumbled upon goroutines page, and there were a lot of goroutines, so quickly downloaded the diagnosis file.

gitea-diagnosis-20250629-202224.zip

@crazyuploader commented on GitHub (Jul 1, 2025): > Please post the gorountine diagnosis zip file. And if possible, please enable performance tracing and share the trace files with us for further analysis. The goroutine diagnosis file is given below, it's when I was checking site administration settings in Gitea, when I stumbled upon goroutines page, and there were a lot of goroutines, so quickly downloaded the diagnosis file. [gitea-diagnosis-20250629-202224.zip](https://github.com/user-attachments/files/21005638/gitea-diagnosis-20250629-202224.zip)
Author
Owner

@lunny commented on GitHub (Jul 2, 2025):

Based on your diagnostic file, the high CPU and memory usage appears to be caused by the Git compare/diff page. This is a known issue when comparing large commits or repositories with significant changes.

If the repositories involved are public, could you please share them with us? That would help us further investigate and potentially reproduce the issue.

Image Image
@lunny commented on GitHub (Jul 2, 2025): Based on your diagnostic file, the high CPU and memory usage appears to be caused by the Git compare/diff page. This is a known issue when comparing large commits or repositories with significant changes. If the repositories involved are public, could you please share them with us? That would help us further investigate and potentially reproduce the issue. <img width="379" alt="Image" src="https://github.com/user-attachments/assets/608d7f54-eaff-4eca-8c0c-c71f874ee215" /> <img width="654" alt="Image" src="https://github.com/user-attachments/assets/05e15fbb-4650-4a33-82dc-095817a3486b" />
Author
Owner

@wxiaoguang commented on GitHub (Jul 2, 2025):

Are you running a public instance? If yes, there might be crawlers. If you'd like to block the crawlers, you can try this: Add a config option to block "expensive" pages for anonymous users #34024 , you can also fine tune the block rules and build your own binary.

@wxiaoguang commented on GitHub (Jul 2, 2025): Are you running a public instance? If yes, there might be crawlers. If you'd like to block the crawlers, you can try this: Add a config option to block "expensive" pages for anonymous users #34024 , you can also fine tune the block rules and build your own binary.
Author
Owner

@crazyuploader commented on GitHub (Jul 2, 2025):

Based on your diagnostic file, the high CPU and memory usage appears to be caused by the Git compare/diff page. This is a known issue when comparing large commits or repositories with significant changes.

If the repositories involved are public, could you please share them with us? That would help us further investigate and potentially reproduce the issue.

Image Image

I am seeing a lot of repeated log entries for the following public repositories -

But it looks like I might be suffering from the fact that the instance is public; crawlers are doing their thing and messing things.

@crazyuploader commented on GitHub (Jul 2, 2025): > Based on your diagnostic file, the high CPU and memory usage appears to be caused by the Git compare/diff page. This is a known issue when comparing large commits or repositories with significant changes. > > If the repositories involved are public, could you please share them with us? That would help us further investigate and potentially reproduce the issue. > > <img alt="Image" width="379" src="https://private-user-images.githubusercontent.com/81045/461303770-608d7f54-eaff-4eca-8c0c-c71f874ee215.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTE0MzE1OTksIm5iZiI6MTc1MTQzMTI5OSwicGF0aCI6Ii84MTA0NS80NjEzMDM3NzAtNjA4ZDdmNTQtZWFmZi00ZWNhLThjMGMtYzcxZjg3NGVlMjE1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA3MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwNzAyVDA0NDEzOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVjMzQyMGFiOGQwMWI1ZTgzMWNiNzMzMGI0NzRkMWZhYjMwZjUyNWY5NjkzMjA3ZjM1N2MzZTY0ZDQ3NmE2MTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.N7WozgeLvNXSQtNeloSsXoUCJw-nA8FYEwvZbNsVK2Q"> <img alt="Image" width="654" src="https://private-user-images.githubusercontent.com/81045/461303900-05e15fbb-4650-4a33-82dc-095817a3486b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTE0MzE1OTksIm5iZiI6MTc1MTQzMTI5OSwicGF0aCI6Ii84MTA0NS80NjEzMDM5MDAtMDVlMTVmYmItNDY1MC00YTMzLTgyZGMtMDk1ODE3YTM0ODZiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA3MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwNzAyVDA0NDEzOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZhZWJmY2RlODc4ODBlMWQ0MzA1ZDA4OTUxZWYzNzA1MWQwNjZhMzg4NmEwNmUwMWU5OThmYzlkYTIzYTU3MmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.MlyAbDZByHqbBHfmtKcEAkwDaTW3DlsObK0sAMr8oY0"> I am seeing a lot of repeated log entries for the following public repositories - - https://github.com/YouROK/TorrServer - https://github.com/Viren070/AIOStreams - https://github.com/mhdzumair/mediaflow-proxy But it looks like I might be suffering from the fact that the instance is public; crawlers are doing their thing and messing things.
Author
Owner

@crazyuploader commented on GitHub (Jul 2, 2025):

Are you running a public instance? If yes, there might be crawlers. If you'd like to block the crawlers, you can try this: Add a config option to block "expensive" pages for anonymous users #34024 , you can also fine tune the block rules and build your own binary.

Yes, I am running a public instance. Thanks for this angle, checked and seeing a lot of Meta, Azure IPs in logs, let me try the config that you have mentioned. But damn these crawlers, hitting where it hurts the most, compare pages, and that too, comparing old tags to the newest one, and tons of significant changes as that!

gitea_instance.log

@crazyuploader commented on GitHub (Jul 2, 2025): > Are you running a public instance? If yes, there might be crawlers. If you'd like to block the crawlers, you can try this: Add a config option to block "expensive" pages for anonymous users [#34024](https://github.com/go-gitea/gitea/pull/34024) , you can also fine tune the block rules and build your own binary. Yes, I am running a public instance. Thanks for this angle, checked and seeing a lot of Meta, Azure IPs in logs, let me try the config that you have mentioned. But damn these crawlers, hitting where it hurts the most, compare pages, and that too, comparing old tags to the newest one, and tons of significant changes as that! [gitea_instance.log](https://github.com/user-attachments/files/21011477/gitea_instance.log)
Author
Owner

@crazyuploader commented on GitHub (Jul 7, 2025):

Are you running a public instance? If yes, there might be crawlers. If you'd like to block the crawlers, you can try this: Add a config option to block "expensive" pages for anonymous users #34024 , you can also fine tune the block rules and build your own binary.

Not facing high CPU & RAM load anymore after this fix, thanks for the info!

@crazyuploader commented on GitHub (Jul 7, 2025): > Are you running a public instance? If yes, there might be crawlers. If you'd like to block the crawlers, you can try this: Add a config option to block "expensive" pages for anonymous users [#34024](https://github.com/go-gitea/gitea/pull/34024) , you can also fine tune the block rules and build your own binary. Not facing high CPU & RAM load anymore after this fix, thanks for the info!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14684