I realized that Rails scoped validation sometimes skipped unexpectedly which results in duplicated record. As a notice, my server is doing some high CPU tasks which regularly fills 80-100% of 6 CPU cores.
Is my validation setting incorrect, or does Rails has a possibility to insert duplicated records in the case of high load environment?
class User < ActiveRecord::Base
has_many :messages
end
class Message < ActiveRecord::Base
belongs_to :user
validates :message, presence: true, uniqueness: {scope: :user_id}, format: {without: /\s/}
end