You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Julian Foad <ju...@wandisco.com> on 2010/08/10 14:31:20 UTC

Upgrade to single-DB: problem locking an empty DB

Upgrading a WC to single-DB:

upgrade_to_wcng() calls

  svn_wc__db_upgrade_begin() to create a new DB, and then
  svn_wc__db_wclock_obtain() and then
  svn_wc__write_upgraded_entries()

The _wclock_obtain() fails because it checks that the node with relpath
"" exists.  Normally in libsvn_wc a new DB is created with
svn_wc__db_init() which inserts a row for relpath "", but
svn_wc__db_upgrade_begin() doesn't.

What's the best solution here?  Not lock it?  Have
svn_wc__db_upgrade_begin() create an initial "" row?  Have
svn_wc__db_wclock_obtain() NOT check for existence of a "" row?  The
first and last options don't sound right.  Creating an initial "" row
does sound right, and requires (presumably) a modification of
svn_wc__write_upgraded_entries().

- Julian


Re: Upgrade to single-DB: problem locking an empty DB

Posted by Greg Stein <gs...@gmail.com>.
On Tue, Aug 10, 2010 at 11:31, Hyrum K. Wright
<hy...@mail.utexas.edu> wrote:
> On Tue, Aug 10, 2010 at 10:26 AM, Julian Foad <ju...@wandisco.com> wrote:
>> On Tue, 2010-08-10 at 15:31 +0100, Julian Foad wrote:
>>> Upgrading a WC to single-DB:
>>>
>>> upgrade_to_wcng() calls
>>>
>>>   svn_wc__db_upgrade_begin() to create a new DB, and then
>>>   svn_wc__db_wclock_obtain() and then
>>>   svn_wc__write_upgraded_entries()
>>>
>>> The _wclock_obtain() fails because it checks that the node with relpath
>>> "" exists.  Normally in libsvn_wc a new DB is created with
>>> svn_wc__db_init() which inserts a row for relpath "", but
>>> svn_wc__db_upgrade_begin() doesn't.
>>>
>>> What's the best solution here?  Not lock it?  Have
>>> svn_wc__db_upgrade_begin() create an initial "" row?  Have
>>> svn_wc__db_wclock_obtain() NOT check for existence of a "" row?  The
>>> first and last options don't sound right.  Creating an initial "" row
>>> does sound right, and requires (presumably) a modification of
>>> svn_wc__write_upgraded_entries().
>>
>> The upgrade function is creating new DBs (or a new single-DB).  Should
>> it perhaps be asking for a lock on the DB as a whole, as distinct from a
>> recursive lock on the WC root directory?  In normal operation, those two
>> mean the same, but maybe here we need to distinguish these as two
>> different concepts.
>
> Where is the upgrade DB being created?  If it's called something like
> 'wc.db.foo', I would think you don't require *any* locking, since no
> other process is going to be looking for that file.  Do the upgrade,
> and then move it in to place before nuking all the old data.

At the moment, it is called 'wc.db'. IIRC, there were some issues
where wc_db calls were made and it looked for wc.db. Not sure if that
is still true (ideally, there would be NO wc_db calls during an
upgrade process).

So... locking is still needed.

Maybe we should allow locks on non-existent rows. Effectively a
"reservation" that something is about to create that row.

Cheers,
-g

Re: Upgrade to single-DB: problem locking an empty DB

Posted by "Hyrum K. Wright" <hy...@mail.utexas.edu>.
On Tue, Aug 10, 2010 at 10:26 AM, Julian Foad <ju...@wandisco.com> wrote:
> On Tue, 2010-08-10 at 15:31 +0100, Julian Foad wrote:
>> Upgrading a WC to single-DB:
>>
>> upgrade_to_wcng() calls
>>
>>   svn_wc__db_upgrade_begin() to create a new DB, and then
>>   svn_wc__db_wclock_obtain() and then
>>   svn_wc__write_upgraded_entries()
>>
>> The _wclock_obtain() fails because it checks that the node with relpath
>> "" exists.  Normally in libsvn_wc a new DB is created with
>> svn_wc__db_init() which inserts a row for relpath "", but
>> svn_wc__db_upgrade_begin() doesn't.
>>
>> What's the best solution here?  Not lock it?  Have
>> svn_wc__db_upgrade_begin() create an initial "" row?  Have
>> svn_wc__db_wclock_obtain() NOT check for existence of a "" row?  The
>> first and last options don't sound right.  Creating an initial "" row
>> does sound right, and requires (presumably) a modification of
>> svn_wc__write_upgraded_entries().
>
> The upgrade function is creating new DBs (or a new single-DB).  Should
> it perhaps be asking for a lock on the DB as a whole, as distinct from a
> recursive lock on the WC root directory?  In normal operation, those two
> mean the same, but maybe here we need to distinguish these as two
> different concepts.

Where is the upgrade DB being created?  If it's called something like
'wc.db.foo', I would think you don't require *any* locking, since no
other process is going to be looking for that file.  Do the upgrade,
and then move it in to place before nuking all the old data.

-Hyrum

Re: Upgrade to single-DB: problem locking an empty DB

Posted by Julian Foad <ju...@wandisco.com>.
On Tue, 2010-08-10 at 16:26 +0100, Julian Foad wrote:
> On Tue, 2010-08-10 at 15:31 +0100, Julian Foad wrote:
> > Upgrading a WC to single-DB:
> > 
> > upgrade_to_wcng() calls
> > 
> >   svn_wc__db_upgrade_begin() to create a new DB, and then
> >   svn_wc__db_wclock_obtain() and then
> >   svn_wc__write_upgraded_entries()
> > 
> > The _wclock_obtain() fails because it checks that the node with relpath
> > "" exists.  Normally in libsvn_wc a new DB is created with
> > svn_wc__db_init() which inserts a row for relpath "", but
> > svn_wc__db_upgrade_begin() doesn't.
> > 
> > What's the best solution here?  Not lock it?  Have
> > svn_wc__db_upgrade_begin() create an initial "" row?  Have
> > svn_wc__db_wclock_obtain() NOT check for existence of a "" row?  The
> > first and last options don't sound right.  Creating an initial "" row
> > does sound right, and requires (presumably) a modification of
> > svn_wc__write_upgraded_entries().
> 
> The upgrade function is creating new DBs (or a new single-DB).  Should
> it perhaps be asking for a lock on the DB as a whole, as distinct from a
> recursive lock on the WC root directory?  In normal operation, those two
> mean the same, but maybe here we need to distinguish these as two
> different concepts.

Or should it ...

  - read the fields of the 'this-dir' entry from 'entries',
  - create a DB with an initial row initialized from those fields,
  - lock that '' dir,
  - read+translate+write the rest of the 'entries'

?

- Julian


Re: Upgrade to single-DB: problem locking an empty DB

Posted by Julian Foad <ju...@wandisco.com>.
On Tue, 2010-08-10 at 15:31 +0100, Julian Foad wrote:
> Upgrading a WC to single-DB:
> 
> upgrade_to_wcng() calls
> 
>   svn_wc__db_upgrade_begin() to create a new DB, and then
>   svn_wc__db_wclock_obtain() and then
>   svn_wc__write_upgraded_entries()
> 
> The _wclock_obtain() fails because it checks that the node with relpath
> "" exists.  Normally in libsvn_wc a new DB is created with
> svn_wc__db_init() which inserts a row for relpath "", but
> svn_wc__db_upgrade_begin() doesn't.
> 
> What's the best solution here?  Not lock it?  Have
> svn_wc__db_upgrade_begin() create an initial "" row?  Have
> svn_wc__db_wclock_obtain() NOT check for existence of a "" row?  The
> first and last options don't sound right.  Creating an initial "" row
> does sound right, and requires (presumably) a modification of
> svn_wc__write_upgraded_entries().

The upgrade function is creating new DBs (or a new single-DB).  Should
it perhaps be asking for a lock on the DB as a whole, as distinct from a
recursive lock on the WC root directory?  In normal operation, those two
mean the same, but maybe here we need to distinguish these as two
different concepts.

- Julian