csmberkeley / scheduler

For managing our students, mentors, and sections
MIT License
8 stars 5 forks source link

Data Race Mentor Section Sign Up #36

Open mikeaboody opened 8 years ago

mikeaboody commented 8 years ago

assignMentor (line 114 in app/models/section.rb) does not take into account race conditions. It is possible that two thread simultaneously pass check on line 115 but then both get assigned to the section via lines 118-121. Big issue in all of this: I don't know how to lock an object in ruby on rails when that object is created via the database. Perhaps we can lock the db row for that section via http://api.rubyonrails.org/classes/ActiveRecord/Locking/Pessimistic.html.

mikeaboody commented 8 years ago

http://thelazylog.com/understanding-locking-in-rails-activerecord/ look into optimistic locking here actually.