git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git .lock file error

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 30, 2010, 20:15 UTC
Message-ID
<7vbp7fhtt0.fsf@alter.siamese.dyndns.org>
In-Reply-To
<AANLkTik364t7WEHOsZcB7FE4Y2gJQNxkXsRvW5guUWCi@mail.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 22 quoted lines
> On Thu, Sep 30, 2010 at 18:00, Nate Parsons <parsons.nate@gmail.com> wrote:
>> OK, so this is definitely a win32 issue. I believe that the perl
>> script is simply creating .lock files too fast for Windows to keep up.
>> Simply trying again fixes the problem for me.
>
> Sounds like something that might do with a non-hacky solution, but I
> don't know what that would be.
>
> ...
> FWIW I think this is more readable, but maybe we want to retry on all
> platforms:
>
>     my $fh;
>     if ($^O eq 'MSWin32' or $^O eq 'cygwin') {
>         # Try 10 times to open our lock file, in case Windows is lagging
>         for my $try (1..10) {
>             sysopen($fh, $db_lock, O_RDWR | O_CREAT);
>             last if $fh;
>         }
>     } else {
>         sysopen($fh, $db_lock, O_RDWR | O_CREAT);
>     }
What exactly does "Windows is lagging" mean in the above?

Why does sysopen() randomly fail and why does it succeed (sometimes) when it immediately gets retried with the same argument? Is this a shared lock and is used by some other processes that drive git? Why does the issue manifest only on Windows? If there are competing processes, wouldn't it exacerbate the situation to run a tight loop to try grabbing the lock without waiting, like the above patch does?

Previous: Ævar Arnfjörð BjarmasonNext: Nate Parsons
Message 5 of 10 in “git .lock file error”
  1. Nate ParsonsSep 13, 2010
  2. Nate ParsonsSep 20, 2010
  3. Nate ParsonsSep 30, 2010
  4. Ævar Arnfjörð BjarmasonSep 30, 2010
  5. Junio C HamanoSep 30, 2010
  6. Nate ParsonsSep 30, 2010
  7. Ævar Arnfjörð BjarmasonSep 30, 2010
  8. Erik Faye-LundSep 30, 2010
  9. Nate ParsonsOct 1, 2010
  10. Erik Faye-LundOct 1, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.