Tuesday, December 9, 2008

Amazon Race Condition

Since our family is spread all over the country (and a good part of the globe) we use Amazon's wish list to communicate what the kids want for Christmas and birthdays. It's nice because the kids don't see what has (or has not) been purchased, but the rest of the family can see what's left on the list. Presumably this avoids getting duplicate presents.

As any computer scientist knows, when you have a single variable and multiple updates going on in parallel, you can end up with what are called race conditions. Basically when multiple writers try to change the variable at the same time, the outcome is non-deterministic. Well yesterday we got caught by that non-determinism. Two uncles in different time zones ended up ordering the same gifts off of the kids' wish lists. Uncle Randy and Uncle Chad were doing their shopping at roughly the same time, unaware of the race condition. Luckily the uncles also sent email confirming their purchases so we were able to adjust the orders satisfactorily!

When I did my PhD in Computer Science back in the late 80s, I never would have thought that non-deterministic access to a single resource over a wide area network would impact my Christmas many years later. I guess it's a geek Christmas after all.

Post a Comment