Race Conditions & ActiveRecord Uniqueness Validation

Wikipedia has a good definition for race conditions but I prefer this one from Search Storage — that I tweaked it just a bit.

A race condition is an undesirable situation that occurs when a device or system attempts to perform two or more operations at the same time, but because of the nature of the device or system, the operations must be executed in the proper sequence to be done correctly.

Uniqueness validation ensures that the value of the specified attributes are unique across the system. In Rails, you’d…