go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.09k stars 5.41k forks source link

Repeated Queue "code_indexer" failed to handle batch of 1 items error logs #31884

Closed MattSG closed 1 week ago

MattSG commented 3 weeks ago

Description

Error logs appear every couple seconds constantly as app is running, appears to come with a memory leak

Setting REPO_INDEXER_ENABLED = false stops the errors

Unaware of RAM usage at the time on the machine but after thousands of these logs, the service appeared to stop itself without reason. The shutdown may not be related to this

Edit: Found these logs in the event viewer that align with the time gitea stopped

Windows successfully diagnosed a low virtual memory condition. The following programs consumed the most virtual memory: gitea.exe (8476) consumed 11716718592 bytes, MsMpEng.exe (8008) consumed 459538432 bytes, and MsSense.exe (3024) consumed 256311296 bytes.
The gitea service terminated unexpectedly.  It has done this 1 time(s).

Maybe this is related to https://github.com/go-gitea/gitea/issues/31565?

2024/08/20 10:52:43 cmd/web.go:355:listen() [I] HTTP Listener: 0.0.0.0:3000 Closed
2024/08/20 10:52:43 .../graceful/manager.go:168:doHammerTime() [W] Setting Hammer condition
2024/08/20 10:52:44 .../graceful/manager.go:184:doTerminate() [W] Terminating
2024/08/20 10:52:44 ...er/issues/indexer.go:120:2() [I] PID: 8940 Issue Indexer closed
2024/08/20 10:52:44 ...exer/code/indexer.go:112:func1() [I] PID: 8940 Repository Indexer closed
2024/08/20 10:52:44 cmd/web.go:214:serveInstalled() [I] PID: 8940 Gitea Web Finished

Indexer config

[indexer]
; ...
REPO_INDEXER_ENABLED = true
REPO_INDEXER_PATH = indexers/repos.bleve
MAX_FILE_SIZE = 1048576
REPO_INDEXER_INCLUDE = 
REPO_INDEXER_EXCLUDE = resources/bin/**

Error log:

2024/08/20 00:00:01 ...s/actions/cleanup.go:60:cleanNeedDeleteArtifacts() [I] Found 0 artifacts pending deletion
2024/08/20 00:00:03 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 75.8ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:03 ...exer/code/indexer.go:128:func2() [E] Codes indexer handler: index error for repo 78: fork/exec C:\Program Files\Git\cmd\git.exe: The filename or extension is too long.
2024/08/20 00:00:03 ...queue/workergroup.go:107:doWorkerHandle() [E] Queue "code_indexer" failed to handle batch of 1 items, backoff for a few seconds
2024/08/20 00:00:05 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 30.1ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:07 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 28.4ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:09 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 28.8ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:10 ...exer/code/indexer.go:128:func2() [E] Codes indexer handler: index error for repo 78: fork/exec C:\Program Files\Git\cmd\git.exe: The filename or extension is too long.
2024/08/20 00:00:10 ...queue/workergroup.go:107:doWorkerHandle() [E] Queue "code_indexer" failed to handle batch of 1 items, backoff for a few seconds
2024/08/20 00:00:11 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 36.6ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:13 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 62.5ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:15 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 84.1ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:17 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 58.0ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:17 ...exer/code/indexer.go:128:func2() [E] Codes indexer handler: index error for repo 78: fork/exec C:\Program Files\Git\cmd\git.exe: The filename or extension is too long.
2024/08/20 00:00:17 ...queue/workergroup.go:107:doWorkerHandle() [E] Queue "code_indexer" failed to handle batch of 1 items, backoff for a few seconds
2024/08/20 00:00:19 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 312.0ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:21 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 85.3ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:23 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 72.6ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:25 ...exer/code/indexer.go:128:func2() [E] Codes indexer handler: index error for repo 78: fork/exec C:\Program Files\Git\cmd\git.exe: The filename or extension is too long.
2024/08/20 00:00:25 ...queue/workergroup.go:107:doWorkerHandle() [E] Queue "code_indexer" failed to handle batch of 1 items, backoff for a few seconds
2024/08/20 00:00:25 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 299.5ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:27 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 60.5ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:30 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 1177.9ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:31 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 122.9ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:32 ...exer/code/indexer.go:128:func2() [E] Codes indexer handler: index error for repo 78: fork/exec C:\Program Files\Git\cmd\git.exe: The filename or extension is too long.
2024/08/20 00:00:32 ...queue/workergroup.go:107:doWorkerHandle() [E] Queue "code_indexer" failed to handle batch of 1 items, backoff for a few seconds
2024/08/20 00:00:33 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 110.7ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:35 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 639.7ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:37 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 364.4ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:39 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 127.0.0.1:51052, 200 OK in 277.2ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2024/08/20 00:00:39 ...exer/code/indexer.go:128:func2() [E] Codes indexer handler: index error for repo 78: fork/exec C:\Program Files\Git\cmd\git.exe: The filename or extension is too long.

Gitea Version

1.22.1 go-git

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.45.2.windows.1

Operating System

Windows Server 2016

How are you running Gitea?

Windows gogit exe on prem running a service

Database

SQLite

yp05327 commented 3 weeks ago

[E] Codes indexer handler: index error for repo 78: fork/exec C:\Program Files\Git\cmd\git.exe: The filename or extension is too long.

This error maybe similar to https://github.com/go-gitea/gitea/issues/29907#issuecomment-2014402614 Windows has maximum path length limitation which is too short in sometimes.

wxiaoguang commented 3 weeks ago

Nope, the root problem is this:

-> search indexer broken: ...exer/code/indexer.go:128:func2() [E] Codes indexer handler: index error for repo 29: fork/exec /usr/bin/git: argument list too long #28584

See my comment https://github.com/go-gitea/gitea/issues/28584#issuecomment-1870130145

Gitea reads the full file list into memory.

Another related problem is the builtin bleve indexer, it sometimes consumes a lot of memory.

lunny commented 3 weeks ago

I sent a PR to try to fix #28584