I have a few places where I generate UUID’s for a large app using application.getUUID(). After about 400,000,000 I got a duplicate UUID. How could this happen? So far I’ve had only 1 duplicate. The value in question was from a UUID generated when it was installed on an old server, and then after being on the new server for about 9 months, a duplicate was generated. Is hardware/mac address part of the algorithm, and if so, isn’t it still supposed to be unique up to 3x10^38?
Hi Scott,
I did some research and there are some interesting facts on Wikipedia about this fenomenon: http://en.wikipedia.org/wiki/UUID:
The J2SE 5.0 release of Java provides a class that will produce 128-bit UUIDs, although it only implements version 3 and 4 generation methods, not the original method (due to lack of means to access MAC addresses using pure Java before version 6). The API documentation for the java.util.UUID class refers to ISO/IEC 11578:1996. Open source implementations supporting MAC addresses on several common operating systems are UUID – generate UUIDs (or GUIDs) in Java and Java Uuid Generator (JUG)
Also take a look at Universally unique identifier - Wikipedia where it states that the chances on getting a conflicting UUID are only slightly bigger than getting hit in the head by a meteorite
Ciao.
Omar
its this java class:
http://docs.oracle.com/javase/6/docs/ap … andom.html
that is used to generate a random 128 bits number.
it should be very unlikely that a duplicate happens , but in theory it could happen…
But why is it called “Unique” then.
I might as well be hit by a meteorite, when I would use UUID’s and they would not be unique !!
My users and management will slowly “kill” me, so I prefer a meteorite
I am using Oracle sequences and I will continue to do so…
Regards,
Watch out, Oracle may just bore you to death Randomness is monkey stuff, it’s the one thing a computer just can’t do properly
Hans Nieuwenhuis:
But why is it called “Unique” then.I might as well be hit by a meteorite, when I would use UUID’s and they would not be unique !!
My users and management will slowly “kill” me, so I prefer a meteoriteI am using Oracle sequences and I will continue to do so…
Regards,
But Oracle sequences are not unique at all… So that can’t be really compared.
(they are not unique when working over multiply databases or offline/sync mode and so on)
I guess Scotts problem is really that it was maybe first created at that older machine with a different kind of secure random implementation
(java 5 compare to java 6 maybe)
But you could test this by writing a small java class that you run on a few different machines (and maybe different vm’s like the latest java 6 and latest java 7)
and they are just doing one thing and that is generating uuids and putting those in the database in an unique column. I would be surprised if that would fail after a few billion inserts…
Lets all call it MUUID. (Mostly Universally Unique IDentifier)
Or BEUUID (Best Effort Universally Unique IDentifier)
according to Sebastiaan: the possibility that Scott made a programming error here is an order of magnitude bigger then it would be possible to get a duplicate
Scott is not a Globally Infallible Servoy Developer (GISD)?
jcompagner:
according to Sebastiaan: the possibility that Scott made a programming error here is an order of magnitude bigger then it would be possible to get a duplicate
LOL. Not a chance!
jcompagner:
I guess Scotts problem is really that it was maybe first created at that older machine with a different kind of secure random implementation
(java 5 compare to java 6 maybe)
Yes, first record was created on an older Server with 32 bit version of java. Then later switch to a 64 bit server with higher java.
Good news is that it hasn’t happened again, so I guess it was just a fluke. We’re at about 1 billion records now and it only happened once.