List:Commits« Previous MessageNext Message »
From:Sergei Golubchik Date:May 13 2008 6:57am
Subject:Re: bk commit into 4.1 tree (tnurnberg:1.2714) BUG#35848
View as plain text  
Hi!

On May 13, Tatjana A Nuernberg wrote:
> ChangeSet@stripped, 2008-05-13 05:38:24+02:00, tnurnberg@stripped +3 -0
>   Bug#35848: UUID() returns UUIDs with the wrong time

>   sql/item_strfunc.cc@stripped, 2008-05-13 05:38:24+02:00,
> tnurnberg@stripped +10 -4
>     correct offset for date/time-part of UUID.
>     also make sure that when we counted into the future earlier
>     (several UUIDs generated in same tick), we only give back
>     as many "borrowed" ticks as we can without duplicating past
>     timestamps.
> 
> diff -Nrup a/sql/item_strfunc.cc b/sql/item_strfunc.cc
> --- a/sql/item_strfunc.cc	2007-01-11 14:44:59 +01:00
> +++ b/sql/item_strfunc.cc	2008-05-13 05:38:24 +02:00
> @@ -3026,10 +3027,15 @@ String *Item_func_uuid::val_str(String *
>    {
>      if (nanoseq)
>      {
> -      tv-=nanoseq;
> -      nanoseq=0;
> +      DBUG_ASSERT((tv > uuid_time) && (nanoseq > 0));
> +      /*
> +        -1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
> +      */
> +      long delta= min(nanoseq, tv - uuid_time -1);
> +      DBUG_PRINT("uuid",("unwinding time by %ld of %ld (%ld -> %ld)",(long)
> delta, (long) nanoseq, (long) uuid_time, (long) tv));
> +      tv-= delta;
> +      nanoseq-= delta;
>      }
> -    DBUG_ASSERT(tv > uuid_time);
>    }
>    uuid_time=tv;
>    pthread_mutex_unlock(&LOCK_uuid_generator);

This is bug#35514 that you're fixing, so you should assign it to
yourself.

As you could see from that bugreport, my idea of a fix was to add a
sleep in case of tv <= uuid_time to limit the rate of UUID generation.

Your solution is ok, but it creates a problem later when nanoseq
overflows. It looks like it's quite possible to overflow it in a
reasonable amount of time. You need a protection for that - and the only
solution I see is set_clock_seq_str().

Regards / Mit vielen Grüssen,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@stripped>
 / /|_/ / // /\ \/ /_/ / /__  Principal Software Engineer/Server Architect
/_/  /_/\_, /___/\___\_\___/  Sun Microsystems GmbH, HRB München 161028
       <___/                  Sonnenallee 1, 85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer
Vorsitzender des Aufsichtsrates: Martin Häring
Thread
bk commit into 4.1 tree (tnurnberg:1.2714) BUG#35848Tatjana A Nuernberg13 May
  • Re: bk commit into 4.1 tree (tnurnberg:1.2714) BUG#35848Sergei Golubchik13 May
Re: bk commit into 4.1 tree (tnurnberg:1.2714) BUG#35848Sergei Golubchik15 May