Commit hook to find out who is holding a lock?

Matt Mackall mpm at selenic.com
Wed May 20 17:18:59 UTC 2015


On Wed, 2015-05-20 at 14:46 +0200, Alban Hertroys wrote:
> On Thu, 2015-02-26 at 17:03 +0100, Alban Hertroys wrote:
> > > Hi all,
> > > 
> > > We're having an issue where files in our single shared repository are 
> > > being locked by 'something' and we're trying to figure out what is 
> causing 
> > > this. The lock conflict only seems to happen on commits or updates, 
> most 
> > > often on commits. Meanwhile the files are being used (read) by a 
> server 
> > > process (tscom3, part of WebFOCUS) on the machine hosting the 
> repository.
> > 
> > Is there an error message? Nothing in Mercurial does file-level locking.
> > 
> > However Windows has a notion of file exclusivity by default that it
> > inherited from its misguided DOS + LanManager youth. Which means that
> > when a poorly-written virus scanner (but I repeat myself) sees something
> > touching a file.. it rushes in to check it and thereby locks you out.
> > So.. probably a virus scanner.
> 
> I think I finally found the culprit. We use the keyword extension to add 
> $Revision$ information to our code[*]. I just had one such locking issue, 
> and in the physical file the string is still '$Revision$', but in the 
> repository it has changed to '$Revision: 0e72bb884edf $'! Is that a 
> plausable conclusion?

(You still didn't send your precise error message, so I'm still
diagnosing based on a vague "something is being locked by something on
Windows".)

The usual "locking" problem on Windows is this:  if you have ANYTHING
else on your machine (web server, database, IDE, virus scanner, backup
program, whatever) that is opening these files at the same time
Mercurial is, you will probably lose.

That's because the DEFAULT for opened files on Windows is "exclude other
processes from reading, writing, or deleting". And just about every app
today still uses this default. Mercurial shares all files it opens, but
this doesn't help if other apps don't. You can't fix the problem in
Mercurial, you have to rewrite the other apps.

(Or switch to Unix.)

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial mailing list