You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Ivan Zhakov <ch...@gmail.com> on 2007/07/08 09:38:55 UTC
Unique transaction names and revision number (was Re: [PATCH] Remove APR ICONV dependency on Windows)
On 7/8/07, Ivan Zhakov <ch...@gmail.com> wrote:
> On 7/8/07, D.J. Heap <dj...@gmail.com> wrote:
> > On 7/7/07, Ivan Zhakov <ch...@gmail.com> wrote:
> > [snip]
> > > And of course primary question: Does it work without my patch? Because
> > > these failures can be related to new txn generation code, committed by
> > > Blair in r25430.
> > >
> >
> >
> > I'm building with trunk r25679 and after backing out r25650, the
> > fs-test.exe passes all tests again. So, either the patch is bringing
> > out some lurking problem, or it is affecting the fs stuff in some way
> > I can't seem to figure out.
> >
> It seems I found way to reproduce problem even without my patch. Many
> fs-test will fail on Windows if you just remove time part from
> generated transaction name in fs_fs. See patch:
>
> Index: subversion/libsvn_fs_fs/fs_fs.c
> ===================================================================
> --- subversion/libsvn_fs_fs/fs_fs.c (revision 25654)
> +++ subversion/libsvn_fs_fs/fs_fs.c (working copy)
> @@ -3195,7 +3195,7 @@
> *p = '-';
>
> process_id = getpid();
> - now = apr_time_now();
> + now = 0; /* It's for testing purposes only! should apr_time_now(). */
>
> unique_basename = apr_psprintf(pool, "%s-%05d-%" APR_TIME_T_FMT,
> hostname_str, process_id, now);
> Index: subversion/libsvn_subr/utf.c
> ===================================================================
> --- subversion/libsvn_subr/utf.c (revision 25654)
> +++ subversion/libsvn_subr/utf.c (working copy)
> @@ -253,7 +253,7 @@
> pool = apr_hash_pool_get(xlate_handle_hash);
>
> /* Try to create a handle. */
> -#if defined( WIN32)
> +#if 0
> apr_err = svn_subr__win32_xlate_open(&handle, topage, frompage, pool);
> #elif defined(AS400)
> apr_err = apr_xlate_open(&handle, (int)topage, (int)frompage, pool);
>
> So it seems the problem of my patch that it made running Subversion
> faster and we got two transactions in the same time :)
>
> Now I'm trying to figure out why this transaction generation code
> fails on Windows.
>
It seems I understand what is happen here.
Before r25430 we've been generated transaction named
"<rev>-<uniquifier>". After r25430 we tried to guarantee transaction
names to be unique and added hostname, pid and time to transaction
name. And for optimization we removed revision number from txn name.
So we got "<hostname>-<pid>-<time>-<uniquifier>" txn names.
Looks good, but bad news that this form of txn names isn't guarantee
to be unique. At least on Windows, where apr_time_now() could return
the same time for different transactions.
And we are fail because fsfs assumes that transaction names unique
between revisions! So it MUST include revision number.
So we have to problems:
1. transaction names still isn't guaranteed to be unique
2. fsfs depends that transaction names unique between revisions, i.e.
include revision number.
--
Ivan Zhakov
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Unique transaction names and revision number (was Re: [PATCH]
Remove APR ICONV dependency on Windows)
Posted by Blair Zajac <bl...@orcaware.com>.
Ivan Zhakov wrote:
> On 7/9/07, Blair Zajac <bl...@orcaware.com> wrote:
>> Ivan Zhakov wrote:
>> > On 7/8/07, Ivan Zhakov <ch...@gmail.com> wrote:
>> >> On 7/8/07, D.J. Heap <dj...@gmail.com> wrote:
>> >> > On 7/7/07, Ivan Zhakov <ch...@gmail.com> wrote:
>> >> > [snip]
>> >> > > And of course primary question: Does it work without my patch?
>> >> Because
>> >> > > these failures can be related to new txn generation code,
>> >> committed by
>> >> > > Blair in r25430.
>> >> > >
>> >> >
>> >> >
>> >> > I'm building with trunk r25679 and after backing out r25650, the
>> >> > fs-test.exe passes all tests again. So, either the patch is
>> bringing
>> >> > out some lurking problem, or it is affecting the fs stuff in some
>> way
>> >> > I can't seem to figure out.
>> >> >
>> >> It seems I found way to reproduce problem even without my patch. Many
>> >> fs-test will fail on Windows if you just remove time part from
>> >> generated transaction name in fs_fs. See patch:
>> >>
>> >> Index: subversion/libsvn_fs_fs/fs_fs.c
>> >> ===================================================================
>> >> --- subversion/libsvn_fs_fs/fs_fs.c (revision 25654)
>> >> +++ subversion/libsvn_fs_fs/fs_fs.c (working copy)
>> >> @@ -3195,7 +3195,7 @@
>> >> *p = '-';
>> >>
>> >> process_id = getpid();
>> >> - now = apr_time_now();
>> >> + now = 0; /* It's for testing purposes only! should
>> apr_time_now(). */
>> >>
>> >> unique_basename = apr_psprintf(pool, "%s-%05d-%" APR_TIME_T_FMT,
>> >> hostname_str, process_id, now);
>> >> Index: subversion/libsvn_subr/utf.c
>> >> ===================================================================
>> >> --- subversion/libsvn_subr/utf.c (revision 25654)
>> >> +++ subversion/libsvn_subr/utf.c (working copy)
>> >> @@ -253,7 +253,7 @@
>> >> pool = apr_hash_pool_get(xlate_handle_hash);
>> >>
>> >> /* Try to create a handle. */
>> >> -#if defined( WIN32)
>> >> +#if 0
>> >> apr_err = svn_subr__win32_xlate_open(&handle, topage, frompage,
>> pool);
>> >> #elif defined(AS400)
>> >> apr_err = apr_xlate_open(&handle, (int)topage, (int)frompage,
>> pool);
>> >>
>> >> So it seems the problem of my patch that it made running Subversion
>> >> faster and we got two transactions in the same time :)
>> >>
>> >> Now I'm trying to figure out why this transaction generation code
>> >> fails on Windows.
>> >>
>> > It seems I understand what is happen here.
>> > Before r25430 we've been generated transaction named
>> > "<rev>-<uniquifier>". After r25430 we tried to guarantee transaction
>> > names to be unique and added hostname, pid and time to transaction
>> > name. And for optimization we removed revision number from txn name.
>> > So we got "<hostname>-<pid>-<time>-<uniquifier>" txn names.
>> >
>> > Looks good, but bad news that this form of txn names isn't guarantee
>> > to be unique. At least on Windows, where apr_time_now() could return
>> > the same time for different transactions.
>>
>> How could that happen? Isn't the resolution of the time in microseconds?
> No, it isn't. On Windows apr_time_now() using GetSystemTime(). In
> returned in microseconds, but precision is approximately 10
> milliseconds.
> http://lists.boost.org/boost-users/2004/05/6635.php
>
>
>>
>> > And we are fail because fsfs assumes that transaction names unique
>> > between revisions! So it MUST include revision number.
>> >
>> > So we have to problems:
>> > 1. transaction names still isn't guaranteed to be unique
>> > 2. fsfs depends that transaction names unique between revisions, i.e.
>> > include revision number.
Actually, this won't fix the problem if you have two transaction started on the
same revision.
>>
>> The real solution, which I need to implement, is to add to fsfs a serial
>> transaction number, much like BDB does. This will make the transaction
>> names much shorter, which is a good thing.
>>
> Agreed. Do you have plans to do this? I really don't like that Windows
> build slave is failing now.
Yes, I am going to work on it.
Regards,
Blair
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Unique transaction names and revision number (was Re: [PATCH]
Remove APR ICONV dependency on Windows)
Posted by Blair Zajac <bl...@orcaware.com>.
Daniel Rall wrote:
> On Mon, 09 Jul 2007, D.J. Heap wrote:
>
>> On 7/9/07, Mark Phippard <ma...@gmail.com> wrote:
>> [snip]
>>> Are we sure this is even the problem? 10 milliseconds is a pretty
>>> small window. Could the test be changed to sleep for 10 milliseconds
>>> to prove this is it?
>>
>> I don't know why APR isn't using the high-resolution timers on
>> Windows, but Ivan's explanation matches the behavior I'm seeing. To
>> test it out, I added a Sleep(100) call to the failing tests where-ever
>> they were creating new revs/txns and the tests consistently pass now.
>
> Adding a serial transaction number to FSFS seems like a higher
> priority than digging into this, since it should really be added
> regardless. I'd rather see time spent implementing it...
Which is what I will do, when I get some cycles :)
Blair
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Unique transaction names and revision number (was Re: [PATCH] Remove APR ICONV dependency on Windows)
Posted by Daniel Rall <dl...@collab.net>.
On Mon, 09 Jul 2007, D.J. Heap wrote:
> On 7/9/07, Mark Phippard <ma...@gmail.com> wrote:
> [snip]
> >Are we sure this is even the problem? 10 milliseconds is a pretty
> >small window. Could the test be changed to sleep for 10 milliseconds
> >to prove this is it?
>
>
> I don't know why APR isn't using the high-resolution timers on
> Windows, but Ivan's explanation matches the behavior I'm seeing. To
> test it out, I added a Sleep(100) call to the failing tests where-ever
> they were creating new revs/txns and the tests consistently pass now.
Adding a serial transaction number to FSFS seems like a higher
priority than digging into this, since it should really be added
regardless. I'd rather see time spent implementing it...
Re: Unique transaction names and revision number (was Re: [PATCH] Remove APR ICONV dependency on Windows)
Posted by "D.J. Heap" <dj...@gmail.com>.
On 7/9/07, Mark Phippard <ma...@gmail.com> wrote:
[snip]
> Are we sure this is even the problem? 10 milliseconds is a pretty
> small window. Could the test be changed to sleep for 10 milliseconds
> to prove this is it?
I don't know why APR isn't using the high-resolution timers on
Windows, but Ivan's explanation matches the behavior I'm seeing. To
test it out, I added a Sleep(100) call to the failing tests where-ever
they were creating new revs/txns and the tests consistently pass now.
DJ
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Unique transaction names and revision number (was Re: [PATCH] Remove APR ICONV dependency on Windows)
Posted by Mark Phippard <ma...@gmail.com>.
On 7/9/07, Ivan Zhakov <ch...@gmail.com> wrote:
> > How could that happen? Isn't the resolution of the time in microseconds?
> No, it isn't. On Windows apr_time_now() using GetSystemTime(). In
> returned in microseconds, but precision is approximately 10
> milliseconds.
> http://lists.boost.org/boost-users/2004/05/6635.php
Are we sure this is even the problem? 10 milliseconds is a pretty
small window. Could the test be changed to sleep for 10 milliseconds
to prove this is it?
--
Thanks
Mark Phippard
http://markphip.blogspot.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Unique transaction names and revision number (was Re: [PATCH] Remove APR ICONV dependency on Windows)
Posted by Ivan Zhakov <ch...@gmail.com>.
On 7/9/07, Blair Zajac <bl...@orcaware.com> wrote:
> Ivan Zhakov wrote:
> > On 7/8/07, Ivan Zhakov <ch...@gmail.com> wrote:
> >> On 7/8/07, D.J. Heap <dj...@gmail.com> wrote:
> >> > On 7/7/07, Ivan Zhakov <ch...@gmail.com> wrote:
> >> > [snip]
> >> > > And of course primary question: Does it work without my patch?
> >> Because
> >> > > these failures can be related to new txn generation code,
> >> committed by
> >> > > Blair in r25430.
> >> > >
> >> >
> >> >
> >> > I'm building with trunk r25679 and after backing out r25650, the
> >> > fs-test.exe passes all tests again. So, either the patch is bringing
> >> > out some lurking problem, or it is affecting the fs stuff in some way
> >> > I can't seem to figure out.
> >> >
> >> It seems I found way to reproduce problem even without my patch. Many
> >> fs-test will fail on Windows if you just remove time part from
> >> generated transaction name in fs_fs. See patch:
> >>
> >> Index: subversion/libsvn_fs_fs/fs_fs.c
> >> ===================================================================
> >> --- subversion/libsvn_fs_fs/fs_fs.c (revision 25654)
> >> +++ subversion/libsvn_fs_fs/fs_fs.c (working copy)
> >> @@ -3195,7 +3195,7 @@
> >> *p = '-';
> >>
> >> process_id = getpid();
> >> - now = apr_time_now();
> >> + now = 0; /* It's for testing purposes only! should apr_time_now(). */
> >>
> >> unique_basename = apr_psprintf(pool, "%s-%05d-%" APR_TIME_T_FMT,
> >> hostname_str, process_id, now);
> >> Index: subversion/libsvn_subr/utf.c
> >> ===================================================================
> >> --- subversion/libsvn_subr/utf.c (revision 25654)
> >> +++ subversion/libsvn_subr/utf.c (working copy)
> >> @@ -253,7 +253,7 @@
> >> pool = apr_hash_pool_get(xlate_handle_hash);
> >>
> >> /* Try to create a handle. */
> >> -#if defined( WIN32)
> >> +#if 0
> >> apr_err = svn_subr__win32_xlate_open(&handle, topage, frompage, pool);
> >> #elif defined(AS400)
> >> apr_err = apr_xlate_open(&handle, (int)topage, (int)frompage, pool);
> >>
> >> So it seems the problem of my patch that it made running Subversion
> >> faster and we got two transactions in the same time :)
> >>
> >> Now I'm trying to figure out why this transaction generation code
> >> fails on Windows.
> >>
> > It seems I understand what is happen here.
> > Before r25430 we've been generated transaction named
> > "<rev>-<uniquifier>". After r25430 we tried to guarantee transaction
> > names to be unique and added hostname, pid and time to transaction
> > name. And for optimization we removed revision number from txn name.
> > So we got "<hostname>-<pid>-<time>-<uniquifier>" txn names.
> >
> > Looks good, but bad news that this form of txn names isn't guarantee
> > to be unique. At least on Windows, where apr_time_now() could return
> > the same time for different transactions.
>
> How could that happen? Isn't the resolution of the time in microseconds?
No, it isn't. On Windows apr_time_now() using GetSystemTime(). In
returned in microseconds, but precision is approximately 10
milliseconds.
http://lists.boost.org/boost-users/2004/05/6635.php
>
> > And we are fail because fsfs assumes that transaction names unique
> > between revisions! So it MUST include revision number.
> >
> > So we have to problems:
> > 1. transaction names still isn't guaranteed to be unique
> > 2. fsfs depends that transaction names unique between revisions, i.e.
> > include revision number.
>
> The real solution, which I need to implement, is to add to fsfs a serial
> transaction number, much like BDB does. This will make the transaction
> names much shorter, which is a good thing.
>
Agreed. Do you have plans to do this? I really don't like that Windows
build slave is failing now.
--
Ivan Zhakov
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Unique transaction names and revision number (was Re: [PATCH]
Remove APR ICONV dependency on Windows)
Posted by Blair Zajac <bl...@orcaware.com>.
Ivan Zhakov wrote:
> On 7/8/07, Ivan Zhakov <ch...@gmail.com> wrote:
>> On 7/8/07, D.J. Heap <dj...@gmail.com> wrote:
>> > On 7/7/07, Ivan Zhakov <ch...@gmail.com> wrote:
>> > [snip]
>> > > And of course primary question: Does it work without my patch?
>> Because
>> > > these failures can be related to new txn generation code,
>> committed by
>> > > Blair in r25430.
>> > >
>> >
>> >
>> > I'm building with trunk r25679 and after backing out r25650, the
>> > fs-test.exe passes all tests again. So, either the patch is bringing
>> > out some lurking problem, or it is affecting the fs stuff in some way
>> > I can't seem to figure out.
>> >
>> It seems I found way to reproduce problem even without my patch. Many
>> fs-test will fail on Windows if you just remove time part from
>> generated transaction name in fs_fs. See patch:
>>
>> Index: subversion/libsvn_fs_fs/fs_fs.c
>> ===================================================================
>> --- subversion/libsvn_fs_fs/fs_fs.c (revision 25654)
>> +++ subversion/libsvn_fs_fs/fs_fs.c (working copy)
>> @@ -3195,7 +3195,7 @@
>> *p = '-';
>>
>> process_id = getpid();
>> - now = apr_time_now();
>> + now = 0; /* It's for testing purposes only! should apr_time_now(). */
>>
>> unique_basename = apr_psprintf(pool, "%s-%05d-%" APR_TIME_T_FMT,
>> hostname_str, process_id, now);
>> Index: subversion/libsvn_subr/utf.c
>> ===================================================================
>> --- subversion/libsvn_subr/utf.c (revision 25654)
>> +++ subversion/libsvn_subr/utf.c (working copy)
>> @@ -253,7 +253,7 @@
>> pool = apr_hash_pool_get(xlate_handle_hash);
>>
>> /* Try to create a handle. */
>> -#if defined( WIN32)
>> +#if 0
>> apr_err = svn_subr__win32_xlate_open(&handle, topage, frompage, pool);
>> #elif defined(AS400)
>> apr_err = apr_xlate_open(&handle, (int)topage, (int)frompage, pool);
>>
>> So it seems the problem of my patch that it made running Subversion
>> faster and we got two transactions in the same time :)
>>
>> Now I'm trying to figure out why this transaction generation code
>> fails on Windows.
>>
> It seems I understand what is happen here.
> Before r25430 we've been generated transaction named
> "<rev>-<uniquifier>". After r25430 we tried to guarantee transaction
> names to be unique and added hostname, pid and time to transaction
> name. And for optimization we removed revision number from txn name.
> So we got "<hostname>-<pid>-<time>-<uniquifier>" txn names.
>
> Looks good, but bad news that this form of txn names isn't guarantee
> to be unique. At least on Windows, where apr_time_now() could return
> the same time for different transactions.
How could that happen? Isn't the resolution of the time in microseconds?
> And we are fail because fsfs assumes that transaction names unique
> between revisions! So it MUST include revision number.
>
> So we have to problems:
> 1. transaction names still isn't guaranteed to be unique
> 2. fsfs depends that transaction names unique between revisions, i.e.
> include revision number.
The real solution, which I need to implement, is to add to fsfs a serial
transaction number, much like BDB does. This will make the transaction
names much shorter, which is a good thing.
Regards,
Blair
--
Blair Zajac, Ph.D.
<bl...@orcaware.com>
Subversion training, consulting and support
http://www.orcaware.com/svn/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Unique transaction names and revision number (was Re: [PATCH] Remove APR ICONV dependency on Windows)
Posted by Travis P <sv...@castle.fastmail.fm>.
On Jul 8, 2007, at 4:38 AM, Ivan Zhakov wrote:
> ... And for optimization we removed revision number from txn name.
> So we got "<hostname>-<pid>-<time>-<uniquifier>" txn names.
>
> Looks good, but bad news that this form of txn names isn't guarantee
> to be unique. ...
So, I guess the <uniquifier> isn't unique enough... :-)
On Jul 9, 2007, at 12:20 PM, Blair Zajac wrote:
> Ivan Zhakov wrote:
>> On 7/9/07, Blair Zajac <bl...@orcaware.com> wrote:
>>> Ivan Zhakov wrote:
>>> > And we are fail because fsfs assumes that transaction names unique
>>> > between revisions! So it MUST include revision number.
>>> >
>>> > So we have to problems:
>>> > 1. transaction names still isn't guaranteed to be unique
>>> > 2. fsfs depends that transaction names unique between
>>> revisions, i.e.
>>> > include revision number.
>
> Actually, this won't fix the problem if you have two transaction
> started on the same revision.
Sometimes for problems like this where there's a small, but not small
enough, window of opportunity for collision, I've found it useful to
make the window vanishingly small by using a random-number
uniquifier. Assuming (and maybe it is too much to assume on all the
systems that Subversion supports via APR), that there's pseudo-rng
such as /dev/urandom or equivalent available, then that might be
enough to ensure the absence of collisions for practical purposes.
-Travis
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org