Re: git .lock file error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 30, 2010 at 11:10 PM, Nate Parsons <parsons.nate@xxxxxxxxx> wrote:
> On Thu, Sep 30, 2010 at 4:15 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>> Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes:
>> > 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);
>> >     }
>> >
>> >     warn "Couldnt open $db_lock: $!\n" unless $fh;'
>
> I agree that this is more readable, although I don't think there needs
> to be separate code sections for each OS. If it's a good OS, it will
> only loop once. You would want to die or croak instead of warn,
> though. It needs the lock to continue, right?
>
>> 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?
>
> All very good questions, and I don't know most of the answers. I know
> that sysopen() is just a thin wrapper around the 'open' system call,
> so the problem has to be with Windows somehow. It probably doesn't
> happen with other OSes because they're better at files :P
>
> I have verified (to the best of my ability) that this problem happens
> even when TortoiseGit is not running, and I don't have cheetah
> installed, and there are no other 'git.exe's running.

Are you running some anti-virus, or from a Dropbox-folder (or
something similar)? If so, these applications tend to open files for a
short while and then release the file handle. This can some times
cause race conditions with other software, like Git.

I haven't looked into this particular code-path for what kind of
hazards might be, but this sounds very much like one such case to me.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]