# Uuidtools across processes

**URL:** <https://www.ruby-forum.com/t/uuidtools-across-processes/93508>\
**Category:** Rails\
**Created:** [April 4, 2006, 7:40am UTC](https://www.ruby-forum.com/t/uuidtools-across-processes/93508 "2006-04-04T07:40:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [April 4, 2006, 7:40am UTC](https://www.ruby-forum.com/t/uuidtools-across-processes/93508/1 "2006-04-04T07:40:19Z")

</div>

Hello,

It seems that there is a small probability of collisions among uuid’s  
produced by uuidtools’ UUID.random\_create() running in concurrent user  
processes on a host (fcgi)? The ~2 bytes extracted from the randomized  
clock\_sequence make a collision unlikely.

[http://rubyforge.org/frs/download.php/8572/uuidtools-1.0.0.zip](http://rubyforge.org/frs/download.php/8572/uuidtools-1.0.0.zip)

Do I miss something?

DD

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [April 4, 2006, 8:06am UTC](https://www.ruby-forum.com/t/uuidtools-across-processes/93508/2 "2006-04-04T08:06:29Z")

</div>

On Apr 3, 2006, at 10:40 PM, Doug D. wrote:

> It seems that there is a small probability of collisions among uuid’s  
> produced by uuidtools’ UUID.random\_create() running in concurrent user  
> processes on a host (fcgi)? The ~2 bytes extracted from the randomized  
> clock\_sequence make a collision unlikely.

It also relies on true\_random, which it claims is a very good random  
number generator “much, much better than the built-in pseudorandom  
number  
generators”.

Since it doesn’t appear to use PIDs after a cursory glance, I’d say  
you’re correct.

Particularly so if it’s running on multiple hosts, because that routine  
doesn’t appear to reference MAC address, making collisions that much  
more  
likely, if ever so rare.

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [April 4, 2006, 2:06pm UTC](https://www.ruby-forum.com/t/uuidtools-across-processes/93508/3 "2006-04-04T14:06:09Z")

</div>

This is a good catch. Someone (possibly me) will need to delve into the  
code and see if it can be patched to reference the MAC address  
appropriately.

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [April 4, 2006, 7:24pm UTC](https://www.ruby-forum.com/t/uuidtools-across-processes/93508/4 "2006-04-04T19:24:18Z")

</div>

Tom M. wrote:

> On Apr 3, 2006, at 10:40 PM, Doug D. wrote:
> 
> > It seems that there is a small probability of collisions among uuid’s  
> > produced by uuidtools’ UUID.random\_create() running in concurrent user  
> > processes on a host (fcgi)? The ~2 bytes extracted from the randomized  
> > clock\_sequence make a collision unlikely.
> 
> It also relies on true\_random, which it claims is a very good random  
> number generator “much, much better than the built-in pseudorandom  
> number generators”.

The concern is that “only” 14 bits of this true\_random (assigned to  
clock\_sequence) is used. The probability of collisions in a fcgi  
configuration is a little too likely. Plus the potential MAC issue, an  
exception code better be in place to re-generate uuid’s.

It would be better if uuidtools’ code were run in the kernel space,  
rather than the user. Or, it embeds a PID in uuid’s.

Another approach is to get uuid’s from a database, i.e. MySQL’s UUID(),  
as long as one DB server runs on a host, effectively making the DB  
server the kernel for all its client processes. However, if MySQL forks  
a user process for each client, not create a pthread, we’re back to  
square one. Is this the case? Any other downsides?

DD
