October 1st, 2009

In the search for the subtle source of the problem, you sometimes overlook the obvious one

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.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.