[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: the retry loop in svn_io_file_lock2()

From: Philip Martin <philip.martin_at_wandisco.com>
Date: Wed, 30 Mar 2011 10:33:42 +0100

Daniel Shahaf <d.s_at_daniel.shahaf.name> writes:

> Why does svn_io_file_lock2() have a retry loop?
>
> The reason given in the code is that some consumer of libsvn_fs wants to run
> a critical section while holding a lock in each of two FSFS filesystems. In
> that case, why isn't the fix just to tell the consumer to, when wanting to
> lock N filesystems, to always lock them in a well-defined order?

First, the knowledge about the locks is entirely within the thread at
present, each thread has no knowledge of what other threads are doing.
You would need to introduce some sort of per-process lock handler.

Secondly, from the comment in the code:

     Process 1 Process 2
     --------- ---------
     thread 1: get lock in repos A
                                       thread 1: get lock in repos B
                                       thread 2: block getting lock in repos A
     thread 2: try to get lock in B *** deadlock ***

when each process takes the first lock it may not know that it will want
the second lock.

-- 
Philip
Received on 2011-03-30 11:34:19 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.