{"thread":{"id":"63520","subject":"ISSUE - Sequential execution failure - Lock auto created between git commands","startedAt":"2025-05-25T14:46:08Z","lastAt":"2025-05-26T13:23:10Z","messageCount":2,"participants":["Yonatan Roth","Patrick Steinhardt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"518859","messageId":"CAJR-fbZ4X1+gN75m2dUvocR6NkowLOZ9F26cjBy8w1qd181OoQ@mail.gmail.com","threadId":"63520","inReplyTo":null,"subject":"ISSUE - Sequential execution failure - Lock auto created between git commands","fromName":"Yonatan Roth","fromEmail":"yroth@paloaltonetworks.com","sentAt":"2025-05-25T14:13:30Z","receivedAt":"2025-05-25T14:46:08Z","isPatch":false,"sender":{"key":"yroth@paloaltonetworks.com","avatar":null},"body":"Hi,\n\n\nUsing a script we run the following set of git commands:\n\ngit branch -a\n\ngit remote -v\n\ngit stash push --all --include-untracked\n\ngit checkout test_git_ver\n\ngit remote -v\n\ngit fetch\n\ngit status --branch --porcelain=v1 -u\n\ngit checkout test_git_ver_workspace\n\n\n\n\nAfter upgrading the git version to - *2.47.2*, we started getting the\nfollowing error:\n\nerror: cannot lock ref 'HEAD': Unable to create '.../.git/*HEAD.lock*':\nFile exists.\n\n\nAnother git process seems to be running in this repository, e.g.\n\nan editor opened by 'git commit'. Please make sure all processes\n\nare terminated then try again. If it still fails, a git process\n\nmay have crashed in this repository earlier:\n\nremove the file manually to continue.\n\nfatal: unable to update HEAD\n\n\n\n\nInvestigating the issue on our side, we found that the failure occurs when\nrunning the last command -\ngit checkout test_git_ver_workspace.\n\nAs well, we noticed that after the \"git fetch\" command there is an *auto *\n*maintenance* execution, it looks like there was a change between git\nversions and now there is an additional flag *--detach *added to\nmaintenance.\nTherefore, we suspect that as a result of git fetch a maintenance detached\n(background) process is created, running in parallel to the general script,\ncreating a lock file that fails the script.\n\n\nAttached trace logs.\n\n\nThis script was running for multiple versions without any issue, it looks\nlike the changes introduce a *regression*.\n\nPlease assist in resolving the issue.\n\n\n\n\nBest regards,\nYonatan Roth\nPalo Alto Networks\n\n\nTrace logs:\n\n\n12:54:52.400869 run-command.c:666       trace: run_command: git rev-list --objects --stdin --not --exclude-hidden=fetch --all --quiet --alternate-refs\n\n12:54:52.400936 run-command.c:758       trace: start_command: /usr/local/libexec/git-core/git rev-list --objects --stdin --not --exclude-hidden=fetch --all --quiet --alternate-refs\n\n12:54:52.483329 run-command.c:1534      run_processes_parallel: preparing to run up to 1 tasks\n\n12:54:52.483384 run-command.c:1561      run_processes_parallel: done\n\n12:54:52.483395 run-command.c:666       trace: run_command: git maintenance run --auto --no-quiet --detach\n\n12:54:52.483475 run-command.c:758       trace: start_command: /usr/local/libexec/git-core/git maintenance run --auto --no-quiet --detach\n\n12:54:52.494826 git.c:479               trace: built-in: git maintenance run --auto --no-quiet --detach"},{"id":"518927","messageId":"aDRrO4x0o0Hit6au@pks.im","threadId":"63520","inReplyTo":"CAJR-fbZ4X1+gN75m2dUvocR6NkowLOZ9F26cjBy8w1qd181OoQ@mail.gmail.com","subject":"Re: ISSUE - Sequential execution failure - Lock auto created between git commands","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-26T13:23:07Z","receivedAt":"2025-05-26T13:23:10Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, May 25, 2025 at 05:13:30PM +0300, Yonatan Roth wrote:\n> Hi,\n> \n> \n> Using a script we run the following set of git commands:\n> \n> git branch -a\n> \n> git remote -v\n> \n> git stash push --all --include-untracked\n> \n> git checkout test_git_ver\n> \n> git remote -v\n> \n> git fetch\n> \n> git status --branch --porcelain=v1 -u\n> \n> git checkout test_git_ver_workspace\n> \n> \n> \n> \n> After upgrading the git version to - *2.47.2*, we started getting the\n> following error:\n> \n> error: cannot lock ref 'HEAD': Unable to create '.../.git/*HEAD.lock*':\n> File exists.\n\nThis sounds similar to the issue reported in [1], please see my reply\nthere. I'll send a patch series the over the next days to address the\nissue.\n\nPatrick\n\n[1]: <CANi7bVAkNc+gY1NoXfJuDRjxjZLTgL8Lfn8_ZmWsvLAoiLPkNg@mail.gmail.com>\n"}]}