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

Context deadline exceeded #20329

Closed
CLanguagePurist opened this issue Jul 12, 2022 · 4 comments · Fixed by #20346
Closed

Context deadline exceeded #20329

CLanguagePurist opened this issue Jul 12, 2022 · 4 comments · Fixed by #20346
Labels

Comments

@CLanguagePurist
Copy link
Contributor

Description

One of the mirrored project, LLVM/LLVM-project seems to have a problem that anytime I try to open it in gitea server, a 500 error is return with context deadline exceeded which seems to suggest that I am hitting a Time to Live timer limit when attempting to open the page for LLVM mirrored project. I've tried asking about it on matrix chat, checked FAQ, and other google search for this but I was not able to find a solution for this yet.

The local gitea server is running on Proxmox server with about 8 cores, 32 gb of RAM, and 1 TB of storage in LVM Ext4 file system. I also can't reproduce this on https://try.gitea.io since I am unable to get an activation email to try replicating the issue.

Gitea Version

1.17.0-rc1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

https://gist.github.com/CLanguagePurist/66337b4af241f89f7f40a5dcc4d40946

Screenshots

giteaerror

Git Version

2.25.1

Operating System

Ubuntu 20.04.4 LTS

How are you running Gitea?

Using executable download for Linux from tagged release for 1.17.0-rc1, gitea-1.17.0-rc1-linux-amd64 from this page and have done SHA256 checksum comparison and they matched with gitea-1.17.0-rc1-linux-amd64.sha256. I have granted this executable privilege to operates on port 80 and 443 and this server is NOT visible to the public internet and required firewall whitelisted address on the LAN to access the server IE my development machine which also runs Linux.

Database

PostgreSQL

@vwbusguy
Copy link

vwbusguy commented Jul 12, 2022

Any clue from system logs? Usually when I get 500 errors like this, it's because of a systems issue, like the database is down or a dependent filesystem isn't mounted or I haven't set the SELinux right labels for it yet.

zeripath added a commit to zeripath/gitea that referenced this issue Jul 12, 2022
Although `WalkGitLog` tries to test for `context.DeadlineExceededErr`
there is a small chance that the error will propagate to the reader
before it is recognised. This will cause the error to propagate up to
`renderDirectoryFiles` and cause a http status 500.

Here we check that the error passed is a `DeadlineExceededErr` or if it
could be unwrapped to one.

Fix go-gitea#20329

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor

There's a subtle bug/race in WalkGitLog:

heaploop:
for {
select {
case <-ctx.Done():
if ctx.Err() == context.DeadlineExceeded {
break heaploop
}
g.Close()
return nil, ctx.Err()
default:
}
current, err := g.Next(treepath, path2idx, changed, maxpathlen)
if err != nil {
if err == context.DeadlineExceeded {
break heaploop
}
g.Close()

At line 357 the error returned is not context.DeadlineExceeded but in fact is a fmt.Errorf("%w - %s", err, stderr)

The err needs to be errors.Unwrap to check if it is a context.DeadlineExceeded.

@CLanguagePurist
Copy link
Contributor Author

CLanguagePurist commented Jul 13, 2022

Any clue from system logs? Usually when I get 500 errors like this, it's because of a systems issue, like the database is down or a dependent filesystem isn't mounted or I haven't set the SELinux right labels for it yet.

The system is pretty nominal overall, I can access LLVM-Project repo from within repository folder on the filesystem, so the files are ok as far as access goes. I haven't activated SELinux/Apparmor for this server since the server is not visible to public internet, require public key authentication for SSH, and only allow connections from my devices via IP address that is reserved on the LAN.

PostgreSQL Database seems to have no log that would indicates an error or issue. I am able to access the gitea database without any problem.

6543 pushed a commit that referenced this issue Jul 13, 2022
* Prevent context deadline error propagation in GetCommitsInfo

Although `WalkGitLog` tries to test for `context.DeadlineExceededErr`
there is a small chance that the error will propagate to the reader
before it is recognised. This will cause the error to propagate up to
`renderDirectoryFiles` and cause a http status 500.

Here we check that the error passed is a `DeadlineExceededErr` via error.Is

Fix #20329

Signed-off-by: Andrew Thornton <art27@cantab.net>
6543 pushed a commit to 6543-forks/gitea that referenced this issue Jul 13, 2022
…a#20346)

* Prevent context deadline error propagation in GetCommitsInfo

Although `WalkGitLog` tries to test for `context.DeadlineExceededErr`
there is a small chance that the error will propagate to the reader
before it is recognised. This will cause the error to propagate up to
`renderDirectoryFiles` and cause a http status 500.

Here we check that the error passed is a `DeadlineExceededErr` via error.Is

Fix go-gitea#20329

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit that referenced this issue Jul 14, 2022
…#20361)

Backport #20346

Although `WalkGitLog` tries to test for `context.DeadlineExceededErr`
there is a small chance that the error will propagate to the reader
before it is recognised. This will cause the error to propagate up to
`renderDirectoryFiles` and cause a http status 500.

Here we check that the error passed is a `DeadlineExceededErr` via error.Is

Fix #20329

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
@CLanguagePurist
Copy link
Contributor Author

Confirming that this is fixed in Release Candidate 2

vsysoev pushed a commit to IntegraSDL/gitea that referenced this issue Aug 10, 2022
…a#20346)

* Prevent context deadline error propagation in GetCommitsInfo

Although `WalkGitLog` tries to test for `context.DeadlineExceededErr`
there is a small chance that the error will propagate to the reader
before it is recognised. This will cause the error to propagate up to
`renderDirectoryFiles` and cause a http status 500.

Here we check that the error passed is a `DeadlineExceededErr` via error.Is

Fix go-gitea#20329

Signed-off-by: Andrew Thornton <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants