A customer was encountering a problem with lots of duplicate GUIDs. How is that possible? The whole point of the GUID generation algorithm is to work hard to avoid duplication. Was one of the fundamental assumptions of the algorithm broken? Maybe there was a duplicate MAC? Was the clock regressing?
One of my colleagues pointed out that in the search for the subtle source of the problem, you sometimes overlook the obvious one. In fact, this is the most common source of problems with so-called duplicate GUIDs. As he so tersely puts it: “A GUID can easily be duplicated by simply copying it.”
In other words, you have a duplicate GUID because you duplicated the GUID. This can happen, for example, if you have a Clone
method on an object which creates an exact duplicate of the object. Since the GUID
is a property of the object, it too gets cloned. Then you add the clone to the same database as the original.
Boom, instant duplicate.
0 comments