Type a keyword and hit enter to start searching. Press Esc to cancel.

Posts Tagged ‘uniqueness validation’

Rails uniqueness validations are not thread safe!  This is a problem when even single threaded Rails servers are susceptible to race conditions.  Luckily, this is an easy problem to avoid. If you have a multi-threaded Rails server like Puma or Passenger Enterprise, use asynchronous background processing with tools like Sidekiq, or have a load balanced environment with multiple web servers then the race condition is real!  Just defining a uniqueness validation will not keep your data unique and can cause a lot of headaches. First, let’s look at why they are not thread safe with a simple example.  Take the […]