GetCompareInfo, AddRemote: exit status 128 - error: could not lock config file config: File exists #13475

Open
opened 2025-11-02 10:43:30 -06:00 by GiteaMirror · 12 comments
Owner

Originally created by @JulienPalard on GitHub (Sep 10, 2024).

Description

When someone is trying to open a pull request on a repo, we're getting a 500 error :

Internal Server Error

Une erreur s’est produite:

GetCompareInfo, AddRemote: exit status 128 - error: could not lock config file config: File exists
fatal: could not set 'remote.1725953120549272064.url' to '/var/lib/gitea/data/gitea-repositories/tala/python-docs-fr.git'
 - error: could not lock config file config: File exists
fatal: could not set 'remote.1725953120549272064.url' to '/var/lib/gitea/data/gitea-repositories/tala/python-docs-fr.git'

Version de Gitea: 1.22.2

Si vous pensez qu'il s'agit d'un bug Gitea, veuillez consulter notre board [GitHub](https://github.com/go-gitea/gitea/issues) ou ouvrir un nouveau ticket si nécessaire.

On the target repo I see the lock file:

root@gitea1:~# ls -lah /var/lib/gitea/data/gitea-repositories/afpy/python-docs-fr.git
total 112K
drwxr-xr-x  8 git git 4.0K Sep 10 05:33 .
drwxr-xr-x 20 git git 4.0K Jul 23  2023 ..
-rw-r--r--  1 git git  134 Jul 26 09:04 FETCH_HEAD
-rw-r--r--  1 git git   21 Nov 17  2022 HEAD
drwxr-xr-x  2 git git 4.0K Nov 17  2022 branches
-rw-r--r--  1 git git  32K Jul 26 09:04 config
-rw-r--r--  1 git git  18K Jul 26 09:04 config.lock

Looks like the lock file is a month old.

Gitea Version

1.22.2

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.30.2

Operating System

Debian 11.11

How are you running Gitea?

Self hosted, installed via ansible: https://git.afpy.org/AFPy/infra/src/branch/main/roles/gitea/tasks/setup.yml

Database

PostgreSQL

Originally created by @JulienPalard on GitHub (Sep 10, 2024). ### Description When someone is trying to open a pull request on a repo, we're getting a 500 error : ``` Internal Server Error Une erreur s’est produite: GetCompareInfo, AddRemote: exit status 128 - error: could not lock config file config: File exists fatal: could not set 'remote.1725953120549272064.url' to '/var/lib/gitea/data/gitea-repositories/tala/python-docs-fr.git' - error: could not lock config file config: File exists fatal: could not set 'remote.1725953120549272064.url' to '/var/lib/gitea/data/gitea-repositories/tala/python-docs-fr.git' Version de Gitea: 1.22.2 Si vous pensez qu'il s'agit d'un bug Gitea, veuillez consulter notre board [GitHub](https://github.com/go-gitea/gitea/issues) ou ouvrir un nouveau ticket si nécessaire. ``` On the target repo I see the lock file: ``` root@gitea1:~# ls -lah /var/lib/gitea/data/gitea-repositories/afpy/python-docs-fr.git total 112K drwxr-xr-x 8 git git 4.0K Sep 10 05:33 . drwxr-xr-x 20 git git 4.0K Jul 23 2023 .. -rw-r--r-- 1 git git 134 Jul 26 09:04 FETCH_HEAD -rw-r--r-- 1 git git 21 Nov 17 2022 HEAD drwxr-xr-x 2 git git 4.0K Nov 17 2022 branches -rw-r--r-- 1 git git 32K Jul 26 09:04 config -rw-r--r-- 1 git git 18K Jul 26 09:04 config.lock ``` Looks like the lock file is a month old. ### Gitea Version 1.22.2 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.30.2 ### Operating System Debian 11.11 ### How are you running Gitea? Self hosted, installed via ansible: https://git.afpy.org/AFPy/infra/src/branch/main/roles/gitea/tasks/setup.yml ### Database PostgreSQL
GiteaMirror added the type/bugissue/workaround labels 2025-11-02 10:43:30 -06:00
Author
Owner

@JulienPalard commented on GitHub (Sep 10, 2024):

I removed the lock file and we're back on tracks, so it "works for me now" but still there's an issue causing this :D

@JulienPalard commented on GitHub (Sep 10, 2024): I removed the lock file and we're back on tracks, so it "works for me now" but still there's an issue causing this :D
Author
Owner

@sbourdeauducq commented on GitHub (Jan 15, 2025):

Also hitting this with Gitea 1.22.6 from nixpkgs + postgresql.

@sbourdeauducq commented on GitHub (Jan 15, 2025): Also hitting this with Gitea 1.22.6 from nixpkgs + postgresql.
Author
Owner

@lunny commented on GitHub (Jan 15, 2025):

This issue occurs mainly when two pull requests are created simultaneously. When creating multiple pull requests, each process adds a remote to the base repository, requiring git to lock the config file. If the lock is active, the git command may exit unexpectedly due to a conflict. A potential solution could be to avoid adding a remote when creating a pull request.

@lunny commented on GitHub (Jan 15, 2025): This issue occurs mainly when two pull requests are created simultaneously. When creating multiple pull requests, each process adds a remote to the base repository, requiring git to lock the config file. If the lock is active, the git command may exit unexpectedly due to a conflict. A potential solution could be to avoid adding a remote when creating a pull request.
Author
Owner

@wxiaoguang commented on GitHub (Jan 16, 2025):

The "one month old" lock file is left by killed git process, not by "two pull requests are created simultaneously"

Gitea needs to clean up these stale lock files

@wxiaoguang commented on GitHub (Jan 16, 2025): The "one month old" lock file is left by killed git process, not by "two pull requests are created simultaneously" Gitea needs to clean up these stale lock files
Author
Owner

@bartvdbraak commented on GitHub (Apr 30, 2025):

We are also running into this issue on a few specific repositories.

2025/04/30 09:17:00 .../web/repo/compare.go:554:ParseCompareInfo() [E] GetCompareInfo: AddRemote: exit status 128 - error: could not lock config file config: File exists
fatal: could not set 'remote.1745997420080980948.url' to '/var/lib/gitea/data/gitea-repositories/blender/blender.git'
 - error: could not lock config file config: File exists
fatal: could not set 'remote.1745997420080980948.url' to '/var/lib/gitea/data/gitea-repositories/blender/blender.git'

Cleaning up these config.lock files manually seem to have done the trick.

@bartvdbraak commented on GitHub (Apr 30, 2025): We are also running into this issue on a few specific repositories. ``` 2025/04/30 09:17:00 .../web/repo/compare.go:554:ParseCompareInfo() [E] GetCompareInfo: AddRemote: exit status 128 - error: could not lock config file config: File exists fatal: could not set 'remote.1745997420080980948.url' to '/var/lib/gitea/data/gitea-repositories/blender/blender.git' - error: could not lock config file config: File exists fatal: could not set 'remote.1745997420080980948.url' to '/var/lib/gitea/data/gitea-repositories/blender/blender.git' ``` Cleaning up these `config.lock` files manually seem to have done the trick.
Author
Owner

@lunny commented on GitHub (May 1, 2025):

What's the path of the config.lock file?

@lunny commented on GitHub (May 1, 2025): What's the path of the `config.lock` file?
Author
Owner

@eliroca commented on GitHub (Jul 22, 2025):

Still hitting this on Gitea 1.24.3.

gitea:/var/lib/gitea/data/gitea-repositories/amorgante/factory.git # la
total 32
drwx------   8 gitea gitea  215 Jul 22 09:12 .
drwx------   3 gitea gitea   25 Mär 18 12:14 ..
drwx------   2 gitea gitea    6 Mär 18 12:14 branches
-rw-------   1 gitea gitea  502 Jun 30 14:35 config
-rw-------   1 gitea gitea    0 Jun 30 14:36 config.lock
-rw-------   1 gitea gitea   73 Mär 18 12:14 description
-rw-------   1 gitea gitea  140 Jun 30 14:35 FETCH_HEAD
-rw-------   1 gitea gitea    0 Mär 18 12:14 git-daemon-export-ok
-rw-r--r--   1 gitea gitea   21 Jul 10 10:16 HEAD
drwx------   6 gitea gitea 4096 Mär 18 12:14 hooks
drwx------   2 gitea gitea   33 Jul 22 09:24 info
drwx------   3 gitea gitea   30 Mär 18 12:29 logs
drwx------ 243 gitea gitea 4096 Jul 22 09:24 objects
-rw-------   1 gitea gitea  289 Mär 18 12:14 packed-refs
drwx------   5 gitea gitea   46 Mär 22 10:37 refs
@eliroca commented on GitHub (Jul 22, 2025): Still hitting this on Gitea 1.24.3. ``` gitea:/var/lib/gitea/data/gitea-repositories/amorgante/factory.git # la total 32 drwx------ 8 gitea gitea 215 Jul 22 09:12 . drwx------ 3 gitea gitea 25 Mär 18 12:14 .. drwx------ 2 gitea gitea 6 Mär 18 12:14 branches -rw------- 1 gitea gitea 502 Jun 30 14:35 config -rw------- 1 gitea gitea 0 Jun 30 14:36 config.lock -rw------- 1 gitea gitea 73 Mär 18 12:14 description -rw------- 1 gitea gitea 140 Jun 30 14:35 FETCH_HEAD -rw------- 1 gitea gitea 0 Mär 18 12:14 git-daemon-export-ok -rw-r--r-- 1 gitea gitea 21 Jul 10 10:16 HEAD drwx------ 6 gitea gitea 4096 Mär 18 12:14 hooks drwx------ 2 gitea gitea 33 Jul 22 09:24 info drwx------ 3 gitea gitea 30 Mär 18 12:29 logs drwx------ 243 gitea gitea 4096 Jul 22 09:24 objects -rw------- 1 gitea gitea 289 Mär 18 12:14 packed-refs drwx------ 5 gitea gitea 46 Mär 22 10:37 refs ```
Author
Owner

@bartvdbraak commented on GitHub (Aug 15, 2025):

@lunny One of developers keeps getting this dormant config.lock created and left behind in his forked repository.

It culminating into him not being able to create PRs until we remove the config.lock files, with a 500 Server Error page detailing the following:

500 Internal Server Error

An error occurred:

GetCompareInfo, AddRemote: exit status 128 - error: could not lock config file config: File exists
fatal: could not set 'remote.1755255233530729352.url' to '/var/lib/gitea/data/gitea-repositories/blender/blender.git'
 - error: could not lock config file config: File exists
fatal: could not set 'remote.1755255233530729352.url' to '/var/lib/gitea/data/gitea-repositories/blender/blender.git'

Gitea Version: 1.24.3

Any idea what is happening here or what we can do to resolve this issue?

I see that more repos have this lock file and it's not clear to me if those are temporary or if they have been left behind:

data/gitea-repositories# find . -name 'config.lock'
./chrislend/blender.git/config.lock
./blender/blender.git/config.lock
./mont29/blender.git/config.lock
./dr.sybren/blender.git/config.lock
@bartvdbraak commented on GitHub (Aug 15, 2025): @lunny One of developers keeps getting this dormant `config.lock` created and left behind in his forked repository. It culminating into him not being able to create PRs until we remove the `config.lock` files, with a 500 Server Error page detailing the following: ``` 500 Internal Server Error An error occurred: GetCompareInfo, AddRemote: exit status 128 - error: could not lock config file config: File exists fatal: could not set 'remote.1755255233530729352.url' to '/var/lib/gitea/data/gitea-repositories/blender/blender.git' - error: could not lock config file config: File exists fatal: could not set 'remote.1755255233530729352.url' to '/var/lib/gitea/data/gitea-repositories/blender/blender.git' Gitea Version: 1.24.3 ``` Any idea what is happening here or what we can do to resolve this issue? I see that more repos have this lock file and it's not clear to me if those are temporary or if they have been left behind: ``` data/gitea-repositories# find . -name 'config.lock' ./chrislend/blender.git/config.lock ./blender/blender.git/config.lock ./mont29/blender.git/config.lock ./dr.sybren/blender.git/config.lock ```
Author
Owner

@lunny commented on GitHub (Aug 15, 2025):

I’ve submitted PR #35151 along with some explanations and have another one after that merged.

As @wxiaoguang mentioned at https://github.com/go-gitea/gitea/issues/32018#issuecomment-2594560477, config.lock files appear when Git subprocess exits abnormally while executing git config or git remote commands. This can happen, for example, if the Gitea instance restarts while a Git subprocess is still running.

Could you confirm whether the timestamps of these lock files correspond to the times when Gitea was restarted?

After PR #35151, we could follow up with another PR to automatically remove config.lock files, since a global lock is already in place before any operations on the config file.

For now, the workaround is to delete these files manually.

@lunny commented on GitHub (Aug 15, 2025): I’ve submitted PR #35151 along with some explanations and have another one after that merged. As @wxiaoguang mentioned at https://github.com/go-gitea/gitea/issues/32018#issuecomment-2594560477, config.lock files appear when Git subprocess exits abnormally while executing `git config` or `git remote` commands. This can happen, for example, if the Gitea instance restarts while a Git subprocess is still running. Could you confirm whether the timestamps of these lock files correspond to the times when Gitea was restarted? After PR #35151, we could follow up with another PR to automatically remove `config.lock` files, since a global lock is already in place before any operations on the config file. For now, the workaround is to delete these files manually.
Author
Owner

@bartvdbraak commented on GitHub (Aug 18, 2025):

@lunny They don't seem to be created corresponding to when Gitea restarted:

ls -lah ./chrislend/blender.git/config.lock ./blender/blender.git/config.lock ./mont29/blender.git/config.lock ./julianeisel/blender.git/config.lock ./dr.sybren/blender.git/config.lock
-rw-rw-r-- 1 gitea gitea  67K Aug 14 17:28 ./blender/blender.git/config.lock
-rw-r--r-- 1 gitea gitea 2.2K Aug 14 16:17 ./chrislend/blender.git/config.lock
-rw-r--r-- 1 gitea gitea 102K Aug 14 18:04 ./dr.sybren/blender.git/config.lock
-rw-r--r-- 1 gitea gitea    0 Aug 15 14:41 ./julianeisel/blender.git/config.lock
-rw-r--r-- 1 gitea gitea  57K Aug 14 18:04 ./mont29/blender.git/config.lock

Gitea is up since 2025-08-13T08:49:15Z

@bartvdbraak commented on GitHub (Aug 18, 2025): @lunny They don't seem to be created corresponding to when Gitea restarted: ``` ls -lah ./chrislend/blender.git/config.lock ./blender/blender.git/config.lock ./mont29/blender.git/config.lock ./julianeisel/blender.git/config.lock ./dr.sybren/blender.git/config.lock -rw-rw-r-- 1 gitea gitea 67K Aug 14 17:28 ./blender/blender.git/config.lock -rw-r--r-- 1 gitea gitea 2.2K Aug 14 16:17 ./chrislend/blender.git/config.lock -rw-r--r-- 1 gitea gitea 102K Aug 14 18:04 ./dr.sybren/blender.git/config.lock -rw-r--r-- 1 gitea gitea 0 Aug 15 14:41 ./julianeisel/blender.git/config.lock -rw-r--r-- 1 gitea gitea 57K Aug 14 18:04 ./mont29/blender.git/config.lock ``` Gitea is up since `2025-08-13T08:49:15Z`
Author
Owner

@lunny commented on GitHub (Aug 19, 2025):

That may caused by an abnormal exit Git Remote or Git config sub processes. If you can find the logs near by the time the config.lock created, which may be helpful.

This can happen, for example, if the Gitea instance restarts while a Git subprocess is still running.

I just mention restarting is one of the possible reasons.

@lunny commented on GitHub (Aug 19, 2025): That may caused by an abnormal exit `Git Remote` or `Git config` sub processes. If you can find the logs near by the time the config.lock created, which may be helpful. > This can happen, for example, if the Gitea instance restarts while a Git subprocess is still running. I just mention restarting is one of the possible reasons.
Author
Owner

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

Not fixed yet

@wxiaoguang commented on GitHub (Sep 2, 2025): Not fixed yet
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13475