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

Cannot allocate memory when viewing repository #2464

Closed
floorish opened this issue Jan 22, 2016 · 81 comments
Closed

Cannot allocate memory when viewing repository #2464

floorish opened this issue Jan 22, 2016 · 81 comments
Labels
💊 bug Something isn't working 🙇‍♂️ help wanted Need your help status: needs reproduce Wait, how did that happen?

Comments

@floorish
Copy link

On v0.8.10 I get a 500 error whenever I want to open a repo with more than one file. I can access the other tabs (Issues/commits etc.), but the Code tab always results in an error.

[Macaron] Started GET /floorish/test for 77.*.*.*
2016/01/22 16:30:14 [...routers/repo/view.go:134 Home()] [E] GetCommitsInfo: GetCommitByPath (/readme.md): fork/exec /usr/bin/git: cannot allocate memory
[Macaron] Completed /floorish/test 500 Internal Server Error in 88.956623ms

Just a simple test repository with a single readme.md works fine, but when I add another file I can't view the Code tab anymore.

Gogs works perfectly fine on v0.8.0 using the exact same config.

Actual memory usage looks fine as well:
screen shot 2016-01-22 at 17 12 02

screen shot 2016-01-22 at 17 12 18

@exmex
Copy link
Contributor

exmex commented Jan 23, 2016

Please test if it still happens in the latest 0.8.22 version.

@floorish
Copy link
Author

There currently aren't any binaries available for that version right? I cannot compile it on the VPS:

$ go get -u -tags "sqlite" github.com/gogits/gogs
go build github.com/codegangsta/cli: /home/git/local/go/pkg/tool/linux_386/compile: fork/exec /home/git/local/go/pkg/tool/linux_386/compile: cannot allocate memory

And cross-compiling locally doesn't work either:

$ env GOOS=linux GOARCH=386 CGO_ENABLED=1 go build -v -tags "sqlite" 
# runtime/cgo
ld: unknown option: --build-id=none
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@unknwon
Copy link
Member

unknwon commented Jan 26, 2016

@floorish how many files in the directory that fails?

@unknwon unknwon added the status: needs feedback Tell me more about it label Jan 26, 2016
@unknwon unknwon added this to the 0.9.0 milestone Jan 26, 2016
@floorish
Copy link
Author

When I add a second file to the repository, I can't open the code tab. When I remove the second file, commit and push with just 1 file it's fine.
So with 2+ files it fails on 0.8.10

@unknwon unknwon added the status: needs reproduce Wait, how did that happen? label Jan 26, 2016
@unknwon
Copy link
Member

unknwon commented Jan 26, 2016

OK... how much memory do you have on VPS... I can't convert for bad math 😓

@floorish
Copy link
Author

$ free -h shows 750MB, so not too much ;) (32bit Debian 7)

screen shot 2016-01-26 at 20 09 53

@unknwon
Copy link
Member

unknwon commented Jan 26, 2016

750MB should be enough...

Gogs works perfectly fine on v0.8.0 using the exact same config.

Just to confirm you're sure about this?

@floorish
Copy link
Author

100% looking at it right now with lots of files

@unknwon
Copy link
Member

unknwon commented Jan 26, 2016

Thanks, got it...

@dakira
Copy link
Contributor

dakira commented Jan 29, 2016

I'm getting this from time to time, but it works after a reload. The log shows messages like these:

2016/01/29 01:26:17 [...routers/repo/view.go:134 Home()] [E] GetCommitsInfo: GetCommitByPath (/tests): fork/exec /usr/bin/git: cannot allocate memory
2016/01/29 01:26:20 [...routers/repo/view.go:134 Home()] [E] GetCommitsInfo: GetCommitByPath (/package.json): fork/exec /usr/bin/git: cannot allocate memory
2016/01/29 01:30:08 [...routers/repo/view.go:134 Home()] [E] GetCommitsInfo: GetCommitByPath (/app): fork/exec /usr/bin/git: cannot allocate memory

There's more than enough memory available, though:

# free -m
             total       used       free     shared    buffers     cached
Mem:          8192       2347       5844        392          0       1455
-/+ buffers/cache:        892       7299
Swap:         4096          0       4096

@unknwon
Copy link
Member

unknwon commented Jan 29, 2016

@dakira how many files in the directory that is having problem?

@unknwon unknwon added the 💊 bug Something isn't working label Jan 29, 2016
@dakira
Copy link
Contributor

dakira commented Jan 30, 2016

@unknwon It's the root of the repo. 12 files, 8 folders.

@unknwon
Copy link
Member

unknwon commented Jan 30, 2016

@dakira thanks, can you help confirm that 0.8.0 works fine?

@dakira
Copy link
Contributor

dakira commented Jan 30, 2016

@unknwon I'm on 0.8.10. I'm not always getting this. When I hit reload all the time, I'm getting this in 1 out of 10 reloads.

If it helps I can set up a new installation with 0.8.0 and try with that.

@unknwon
Copy link
Member

unknwon commented Jan 30, 2016

@dakira that would be best to try again 0.8.0, so we can be more sure about where the problem is.

@dakira
Copy link
Contributor

dakira commented Jan 30, 2016

Looks like I can't reproduce this with 0.8.0 while I can with 0.8.10 and 0.8.25 (by mercilessly hitting F5). Edit: I tried some more. This definately doesn't exist in 0.8.0.

@unknwon
Copy link
Member

unknwon commented Jan 30, 2016

@dakira Got it, thank you!

@dakira
Copy link
Contributor

dakira commented Feb 2, 2016

Can confirm for develop, too.

@dakira
Copy link
Contributor

dakira commented Feb 8, 2016

This happens more often when there are more files and when Gogs has been running longer. It doesn't happen for a while after it has been restarted. Again with tons of memory available. Is there a workaround @unknwon ?

@unknwon
Copy link
Member

unknwon commented Feb 8, 2016

@dakira Are you using precompiled binary or installed from source code?

@dakira
Copy link
Contributor

dakira commented Feb 9, 2016

As I mentioned, I can also reproduce this in develop, compiled from source code (as of 7 days ago).

@floorish
Copy link
Author

Just to confirm, on 0.8.25 (precompiled, 386) I get the same error.

I installed Gogs 0.8.25 (precompiled, amd64) on a different vps, there it works fine. They're totally different setups though, so hard to compare unfortunately.

@dakira
Copy link
Contributor

dakira commented Feb 12, 2016

@unknwon as this is a regression, can I help somehow locating the problem if you can't reproduce yourself?

@ultimatedirty
Copy link

Same problem on 0.8.25.0129 (precompiled, amd64). Used Gogs Migration from freebsd/freebsd-ports and get those 500 errors in. Used Gogs Migration on gogits/gogs and its seems OK.

VPS: Ubuntu 14.04, 6 vCores, 8GB Ram

@dakira
Copy link
Contributor

dakira commented Feb 17, 2016

@ultimatedirty what exactly do you mean by Gogs Migration?

@ultimatedirty
Copy link

@dakira Top Menu Create -> New Migration

@ghost
Copy link

ghost commented Mar 3, 2016

Thanks for answering :)
free -h shows:
total used free shared buffers cached
2.0G 225M 1.8G 68M 0B 165M

@unknwon
Copy link
Member

unknwon commented Mar 3, 2016

@YugoCode thanks for the prove!

@NiklasRosenstein
Copy link

I just upgraded to 0.9.13.0318 and it seems to run well, though it feels very slow. When I go to the "Code" page to view the files on the master branch, the page loads in ~1800ms. However, when I go to view a single source file, it loads in ~400ms.

Is this difference in the page load time expected? Note that I do not know how Gogs actually gets the data from git. (Does it check out the whole working tree to get a list of the files?)

@unknwon
Copy link
Member

unknwon commented Mar 23, 2016

@NiklasRosenstein #1518

@dakira
Copy link
Contributor

dakira commented Apr 14, 2016

This issue is back in 0.9.20.0404.

@Pastew
Copy link

Pastew commented Apr 18, 2016

Hi, I'm new to Gogs but I have the same error. I'm opening 10MB, one-commit newly pushed repo and I have 500 Internal Server Error in browser and in console:
[...routers/repo/view.go:136 Home()] [E] GetCommitsInfo: GetCommitByPath (/.idea): fork/exec /usr/bin/git: cannot allocate memory

Gogs version 0.9.13.0318

top output:

top - 14:45:28 up 49 min,  2 users,  load average: 0.04, 0.01, 0.00
Tasks:  40 total,   1 running,  39 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.1 us,  1.1 sy,  0.0 ni, 97.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   1048576 total,   308760 used,   739816 free,        0 buffers
KiB Swap:   524288 total,        0 used,   524288 free.   229948 cached Mem

@lucianolorenti
Copy link

lucianolorenti commented May 7, 2016

I ran into the same problem with my server. Apparently it is related with the number of concurrent tasks performed in GetCommitsInfo of the Entries type: tree_entry.go..
I changed
taskChan := make(chan bool, 10)
to
taskChan := make(chan bool, 2)

and,for now, I can not cause the error again.

@bkcsoft
Copy link
Contributor

bkcsoft commented May 13, 2016 via email

@unknwon
Copy link
Member

unknwon commented May 23, 2016

@bkcsoft yes, I think it is possible as a config option.

@y4my4my4m
Copy link

y4my4my4m commented Jun 29, 2016

@unknwon
Getting this too in 0.9.28.0527 almost 50% of the time.
Only getting this error viewing the root of the repository (which is owned by an organization)

Log

2016/06/29 14:24:19 [...routers/repo/view.go:138 Home()] [E] GetCommitsInfo: GetCommitByPath (/app.js): fork/exec /usr/bin/git: cannot allocate memory
2016/06/29 14:24:20 [...routers/repo/view.go:138 Home()] [E] GetCommitsInfo: GetCommitByPath (/node_modules): fork/exec /usr/bin/git: cannot allocate memory
2016/06/29 14:24:24 [...routers/repo/view.go:138 Home()] [E] GetCommitsInfo: GetCommitByPath (/views): fork/exec /usr/bin/git: cannot allocate memory
2016/06/29 14:24:29 [...routers/repo/view.go:138 Home()] [E] GetCommitsInfo: GetCommitByPath (/views): fork/exec /usr/bin/git: cannot allocate memory
2016/06/29 14:25:46 [...routers/repo/view.go:138 Home()] [E] GetCommitsInfo: GetCommitByPath (/public): fork/exec /usr/bin/git: cannot allocate memory
2016/06/29 14:25:52 [...routers/repo/view.go:138 Home()] [E] GetCommitsInfo: GetCommitByPath (/package.json): fork/exec /usr/bin/git: cannot allocate memory
2016/06/29 14:25:54 [...routers/repo/view.go:138 Home()] [E] GetCommitsInfo: GetCommitByPath (/views): fork/exec /usr/bin/git: cannot allocate memory
2016/06/29 14:26:20 [...routers/repo/view.go:138 Home()] [E] GetCommitsInfo: GetCommitByPath (/public): fork/exec /usr/bin/git: cannot allocate memory

Memory:

              total        used        free      shared  buff/cache   available
Mem:           2.0G         44M        1.4G        162M        534M        1.7G
Swap:          4.0G          0B        4.0G

Any help?

I'm running on CentOS 7 and MySQL.


Edit:
taskChan := make(chan bool, 2)
seems to help, i was using centos7 packager, but now im building from scratch...just feels a bit unstable somehow.

Also noticed you've added
LimitMEMLOCK=infinity
LimitNOFILE=65535
To the gogs.service

Does this really work?

@unknwon
Copy link
Member

unknwon commented Jun 29, 2016

@ubiko sorry, but really have no ideas how this problem is caused... maybe there are some limitation options we're not noticed because this is not happening to all machines (that's the hardest part for debugging).

@y4my4my4m
Copy link

@unknwon

taskChan := make(chan bool, 2) is fixing it...but does it mean it's slower than if it was set at 10?

@unknwon
Copy link
Member

unknwon commented Jul 1, 2016

@ubiko yes, that's right...

@bkcsoft
Copy link
Contributor

bkcsoft commented Jul 3, 2016 via email

@ghost
Copy link

ghost commented Jul 3, 2016

@ubiko The line of code you posted is fixing the problem??? I don't care if it's slow, I need it to work at least. Where do I have to put the line? Or could you build a binary with this fixed line?

Thank you :)

@sjahreis
Copy link

sjahreis commented Jul 3, 2016

@bkcsoft In my case it's not related to ulimit. No limitations configured...

Please add as config option!

@y4my4my4m
Copy link

@unknown no worries, it's a pretty hard issue to figure out also. I gotta thank you for making Gogs before I'd complain. 👍

@YugoCode Yes it is fixing it. It's more of a workaround than a fix though, credit goes to: @lucianolorenti (Higher up in the comments) . You can fix it by modifying tree_entry.go . You need to work from the source, you can't fix this if you're using a docker/packager. You need to build the app again.
Good luck.

@unknwon unknwon removed the status: needs feedback Tell me more about it label Jul 22, 2016
@toudi
Copy link

toudi commented Aug 5, 2016

I was also affected by this issue on the VPS. I am wondering whether maybe this has something to do with number of cores available? Because on my VPS I got this 500, but on my OrangePi gogs runs flawlessly and I don't have this error. The only difference seems to be in the architecture (VPS is i386 vs arm7 on the OrangePi) and the number of cores (OrangePi has 4 cores whereas my VPS has only one).

If this is false impression, please tell me and I'll remove my comment so that I don't introduce unnecesary mess.

Thank you so much for gogs!

@botboe
Copy link

botboe commented Aug 31, 2016

As @sjahreis already mentioned, a config option would be awesome!

@botboe
Copy link

botboe commented Nov 29, 2016

Something new here?

@y4my4my4m
Copy link

@toudi @Mad-Onion
I believe it has to do with available Swap memory on your VPS setup.
Either increase swap capacity on your VPS (if your host allows this) or your setup, you might be out of luck (as I was, decided to change environment)

@WolfgangKluge
Copy link

There's the pull request gogs/git-module#26 from 0xbaadf00d, but unfortunetely no progress since one month...

@dakira
Copy link
Contributor

dakira commented Dec 1, 2016

@WolfgangKluge This project seems to be dead. There is an extremely active fork here: https://github.com/go-gitea/gitea. I've been asked to wait for the 1.0 release before I switch over. But that should be soon.

@unknwon
Copy link
Member

unknwon commented Feb 19, 2017

Please notify when this happens again.

@unknwon unknwon closed this as completed Feb 19, 2017
@paradajz
Copy link

Happens to me as well. CentOS 6.8. Seemingly random behaviour. Latest Gogs. Let me know if you need more details.

@extraymond
Copy link

Happened in a docker container on google compute engine.
Hope this gets fixed, thx.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💊 bug Something isn't working 🙇‍♂️ help wanted Need your help status: needs reproduce Wait, how did that happen?
Projects
None yet
Development

No branches or pull requests